-
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///
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
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>
-
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?
-
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
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
Code:
user name is .. NULL
customer has been added to the DB
-
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.
-
i totally understand now i will request it through the controller
thanks
miki