Suneet Shah wrote:
> Hi Craig, Thanks for your reply. Your first approach seems like what
> I am looking for, but hava a couple of followup questions. > * Form
> submit goes to a servlet If in the jsp pages I specify a useBean and
> mark it as * and thenspecify a servlet in the action method, will the
> form fields get set in the bean automatically? ie. I guess I am
> uncertain of how and whenthings actually make it into the bean.
> *** To use the "*" approach to populating bean properties,
> *** you have to post directly to a JSP page. If you're posting
> *** to a servlet instead, it is up to the servlet to set whatever
> *** bean properties you need, before it forwards the request.
> > * Servlet initiates whatever business processes
> are requested, and synthesizes results in one
> or more beans. same as above, how do things make into the bean, when
> a servlet is specified in the form action
> *** As above, it is up to the servlet to do this for you. Since
> *** it's just Java code, it can do whatever it wants. Once the
> *** forwarding is done, the bean will have its properties already
> *** set to the values stored by your servlet, so no additional
> *** <jsp:setProperty> calls are necessary.
>
> *** The key thing to remember is that the objects you store with
> *** HttpSession.putValue(), for example, are *exactly* the same
> *** objects that you reference with <jsp:useBean scope="session">
> *** actions. The name you store the value under has to match
> *** the "id" value in your useBean for the system to match them up.
> *** Likewise, objects you store with request.setAttribute() are
> *** exactly the same objects you reference with
> *** <jsp:useBean scope="request"> actions in the JSP page.
> * The beans are stored as attributes of the request
> (if they are only needed for the response I am about
> to generate) or the user's session (if they need to
> last beyond the processing of this request. How do get a referece to
> the bean - request.getparmeter(beanName)?
> *** Yes, this is correct, but remember that each request starts with
> *** no attributes at all. The point of request attributes (which are
> the
> *** same as things you address with <jsp:useBean scope="request">)
> *** is to provide temporary storage for objects required to satisfy
> this
> *** particular request. They are thrown away between requests.
>
> *** If you wanted to retrieve an existing session object in your
> servlet,
> *** you would use session.getValue(beanName) instead. These objects
> *** exist until you remove them, or until the session is invalidated
> or
> *** times out.
> Thanks a lot. Suneet
NOTE: HTML mail makes a real mess in some mail readers -- ***Please***
send text-only mail to mailing lists.
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