Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JSP form values lost upon servlet request (RequestDispatcher)

843840Feb 25 2002 — edited Feb 27 2002
Hello,
I have a query screen (jsp) that calls a servlet and gets results. However, although the results or errors display just fine (I do a setAttribute for them), I lose the initial values in the query form (values that the user input - which are stored in the request object). Shouldn't those values be maintained and displayed, since I'm using the RequestDispatcher and thus, I should have the same request object? Thank you, C Turner

*****My JSP (the related code)*****

<jsp:useBean id="form" class="com.foo.ActivityBean" scope="session">
<jsp:setProperty name="form" property="*"
</jsp:useBean>
<HTML>
<BODY>
<FORM ACTION="ActivityFormHandler" METHOD="POST">
<P><B>From Date</B>
<INPUT TYPE="TEXT" NAME="fromDate" SIZE="9" VALUE="<jsp:getProperty name="form" property="fromDate"/>">
<P><B>To Date</B>
<INPUT TYPE="TEXT" NAME="fromDate" SIZE="9" VALUE="<jsp:getProperty name="form" property="toDate"/>">


*****Java from my HttpServlet, ActivityFormHandler (acting as a formhandler)*****

if (errors.size() == 0) {
ActivityBean myActivityBean = new ActivityBean();
myActivityBean.setBeanQueryValues(acctNumber, department, fromDate, toDate);
Vector resultsVector = null;
try {
resultsVector = myActivityBean.executeQuery();
} catch (CreateException ce) {
errors.add("There was a problem retrieving the requested data from the database.");
}
request.setAttribute("results", resultsVector);
} else {
//Data is not okay.
String[] errorArray = (String[])errors.toArray(new String[errors.size()]);
request.setAttribute("errors", errorArray);
}
RequestDispatcher rd;
rd = getServletContext().getRequestDispatcher("/public_html/ActivityQuery.jsp");
//rd.forward(request, response);
rd.include(request, response);
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 27 2002
Added on Feb 25 2002
1 comment
335 views