Here's what I want to do. It seems simple, but I can't get it to work. JSP1 - user fills out form, submits to JSP2. JSP2 populates the form values in a Bean and displays data, and offers user option to return and modify (history.back()), or submit to Servlet. I've come up with three different options, and each has problems.
OPTION 1: JSP1 - standard html form, submits to JSP2
<form name="testform" method="post" action="jsp2.jsp">
...
City: <input name="currentCity" type="text" />
JSP2 -
<jsp:useBean id="workorder" type="com.mycompany.app.WorkorderBean" class="com.mycompany.app.WorkorderBean" scope="request">
<jsp:setProperty name="workorder" property="*" />
</jsp:useBean>
...
currentCity: ${workorder.currentCity}
Problem -when JSP2 submits to controller, and I call WorkorderBean workorder = (WorkorderBean) request.getAttribute("workorder");
it returns null. So 'scope=request' doesn't make it from JSP to servlet.
OPTION 2: Same scenario, but on JSP2 use 'scope=session'.
Problem: when the user chooses to go back to JSP1 and modify data, then re-submits to JSP2, JSP2 does not use the new values, because it already has the bean as a session bean.
Question: Is there a way I can clear out the session bean when I submit from JSP1? I don't think I can do this with Javascript.
OPTION 3: Have JSP1 submit to Servlet, which formats the session bean and sends to JSP2.
Problem: When user choose to go back from JSP2 to JSP1 to make changes, all data is lost in the form.
How can I make this work?