Re: form bean and session attribute
Not only is 'two.jsp' not required, it's kind of a mistake. You're
using 'two.jsp' to handle logic, i.e., parsing request parameters into a
bean, then forwarding to a .java-sourced servlet to handle display.
Thufir Hawat wrote:
It's basically lifted from:
That example isn't following best practices. That whole business with
"continue" is not necessary, and you certainly don't need to put the "form
bean" in the session with a proper architecture, at least not for the way that
site uses it.
I'll ask the question differently, maybe that will help. How do you send
a form bean to a servlet? At some point that view data needs to make its
way to a servlet.
In the first place you don't send a "form bean" in the request, you send
request parameters. The servlet that is the target of the form 'action'
attribute automatically receives those parameters, so just by submitting the
form you are getting them to the servlet.
Use a .java-sourced servlet as the 'action' target, and use the
'HttpServletRequest' object to obtain the parameters and copy them into your bean.
You store the bean in the request context to get it out to the display JSP.
Start here for real information on how to use servlets and JSPs:
Marty Hall is one of the best for this type of information.
Read the document there on the Model-View-Controller (MVC) architecture
and google for more on that topic after you've read it.
You extract a 'RequestDispatcher'
from the request via the 'getRequestDispatcher()' method to handle the
'forward()' to the display JSP.
There's more, but this is a start.