Results 1 to 5 of 5
  1. #1
    miko5054 is offline Member
    Join Date
    Mar 2010
    Posts
    50
    Rep Power
    0

    Default use bean problem

    im trying to use a use-bean tag to submit information into the DB but all the data from the form appear to be null
    i cant see what is wrong...

    the form///
    Java Code:
     <%@page import="mBank.MBank"%>
    <%@ page language="java" contentType="text/html; charset=UTF-8"
    	pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    
    <%@ include file="/admin.jsp"%>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    </head>
    <body>
    <form  method="post" action="addcusresulte.jsp">
    password<input
    	type="text" name="pass"><br>
    first name<input type="text" name="firstname"><br>
    last name<input type="text" name="lastname"><br>
    addresses<input type="text" name="addresses"><br>
    email<input type="text" name="email"><br>
    phone number<input type="text" name="phonenumber"><br>
    comments<input type="text" name="comments"><br>
    <input type="submit" name="submit"><input type="reset"
    	name="reset"></form>
    
    
    
    </body>
    </html>

    nextpage
    Java Code:
      <%@ page language="java" contentType="text/html; charset=UTF-8"
    	pageEncoding="UTF-8"%>
    <%@page import="il.co.mbank.data.Customer"%>
    <%@page import="mBank.MBank"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <%@ include file="/admin.jsp" %>
    <jsp:useBean id="user" class="il.co.mbank.data.Customer" scope="session"></jsp:useBean>
    <jsp:setProperty name="user" property="*" />
    
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    </head>
    <body>
     
    <%--
    	MBank bank = MBank.instance();
    	bank.addClient(user.getPassword(), user.getFirstName(),
    			user.getLastName(), user.getAddrese(), user.getEmail(),
    			user.getPhoneNum(), user.getComments());
    --%>
    
    
    user name is ..<%=user.getFirstName() %>
    <h4>customer has been added to the DB</h4>
    --</body>
    </html>

  2. #2
    Fortunato is offline Member
    Join Date
    Oct 2010
    Posts
    4
    Rep Power
    0

    Default

    Just to clarify...
    The first page displays your form and lets the user fill it in and submit it to the page addcusresulte.jsp

    Is the code under "nextpage" in your post what is in addcusresulte.jsp?

  3. #3
    miko5054 is offline Member
    Join Date
    Mar 2010
    Posts
    50
    Rep Power
    0

    Default

    this code invoking a method that suppose to insert new data into the DB
    i comment it because i dont want to receive NULL EXCEPTION
    Java Code:
       
    <%--
    	MBank bank = MBank.instance();
    	bank.addClient(user.getPassword(), user.getFirstName(),
    			user.getLastName(), user.getAddrese(), user.getEmail(),
    			user.getPhoneNum(), user.getComments());
    --%>
    the output for the code now will be

    Java Code:
    user name is .. NULL
    customer has been added to the DB

  4. #4
    Fortunato is offline Member
    Join Date
    Oct 2010
    Posts
    4
    Rep Power
    0

    Default

    You have to read the response object to get the form data. That should be done, in your case, in addcusresulte.jsp (directly or indirectly). Getting nulls maybe a sign that your not reading the response object or you are not putting the values from the response object in Mbank.

    As I don't see code that reads the response object I can only speculate on want your problem is. That's why I asked the question I did in my first post.

  5. #5
    miko5054 is offline Member
    Join Date
    Mar 2010
    Posts
    50
    Rep Power
    0

    Default

    i totally understand now i will request it through the controller

    thanks
    miki

Similar Threads

  1. Problem retrieving data to JSP from Bean [using Hibernate]
    By linking90 in forum JavaServer Pages (JSP) and JSTL
    Replies: 11
    Last Post: 09-09-2010, 05:50 PM
  2. Problem with Session Scope while using with Java Bean
    By sulthanmytheen in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 03-27-2009, 10:50 AM
  3. UREGENT-accessing session bean ok but entity bean
    By parimal in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 08-28-2008, 01:34 PM
  4. Replies: 0
    Last Post: 03-30-2008, 10:03 AM
  5. Replies: 0
    Last Post: 09-26-2007, 08:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •