needArchitectureHelp wrote:
> Using the JSP model for using a bean to store form data (i.e. use
> <jsp:setProperty> to store form input fields - use <jsp:getProperty> to
> retrieve data) - How does Java/server keep track of the beans from JSP to
> JSP page? For example - I use 3 JSP pages to process one form - first JSP
> page accept input - second JSP validate input (if invalid back to first
> page) - third JSP update database.
>
> If 5 users are inputting data into the form - how are the beans tracked?
>Serialization?
>
> Does scope="session" do this automatically? With more than 1 user? How do I
>release/reset the bean if I only need the bean for a few jsp pages - but user does
>more during the session?
>
Yes, scope=session does this for you. JSP pages take advantage of the Servlet API
support for session management, which uses a cookie (or URL rewriting) to pass a
session identifier back
and forth to the client browser. Associated with the session is a set of attributes
(typically stored in a Hashtable) whose names match the "ids" of your session-scoped
beans. Such
attributes are maintained individually for each user in their own session, until the
session is invalidated or times out, or until you explicitly remove that attribute.
>
> Is this the best way to validate (i.e. using beans)? Is there a better/easier way?
>
I handle user input on a multi-page form the same way you are doing it. Where we
differ is in the final processing -- I use a servlet that calls an appropriate action
class method,
depending on which action needs to be taken. This approach better separates business
logic and presentation logic (you are going to be tempted to combine them, especially
in the third
page that stores the info into the database). It has been variously called the "Model
2" architecture (named after what it was called in the JSP 0.92 specification), or the
JSP+servlets
architecture, and has been extensively discussed on both the JSP-INTEREST and
SERVLET-INTEREST mailing lists. Check the archives for more information.
Craig McClanahan
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html