Brian Schaefer wrote:

> Yes, but the <jsp:useBean.. tag takes care of not creating a new instance of
> the Bean if one already exists, whereas the Servlet method as described by
> Craig below replaces the instance with a new one on each call.  If other
> properties are needed, this make a difference.
> Brian
>

Not that tough to deal with.  Change the code to:

    HttpSession session = request.getSession(true);
    UserInfoBean uib = (UserInfoBean) session.getValue("theUserInfoBean");
    if (uib == null)
        session.putValue("theUserInfoBean", uib);
     uib.setUserName(request.getParameter("userName");
     uib.setUserpassword(request.getParameter("userpassword");

Craig


>
> > Sreekumar Pillai wrote:
> >
> > > 1. How do you use jsp:setProperty tag along with <form
> > > action=Model2Servlet>?
>
> > The <jsp:setProperty> element is only useful if the
> > destination of your form submit
> > is another JSP page.  Then, you would do something like this:
> >
> >     <jsp:useBean id="theUserInfoBean" scope="session"
> > class="UserInfoBean">
> >         <jsp:setProperty name="theUserInfoBean" property="userName"/>
> >         <jsp:setProperty name="theUserInfoBean"
> > property="userpassword"/>
> >     </jsp:useBean>
> >
> > If you are submitting to a servlet instead, you would not be
> > doing this -- instead,
> > you'd be doing the servlet equivalent:
> >
> >     UserInfoBean uib = new UserInfoBean(...);
> >     uib.setUserName(request.getParameter("userName");
> >     uib.setUserpassword(request.getParameter("userpassword");
> >     HttpSession session = request.getSession(true);
> >     session.putValue("theUserInfoBean", uib);
> >
> > >
> > > Thanks in advance. Special thanks to Craig for the
> > excellent response to my
> > > earlier question regarding global objects.
> > >
> > > Sree
> > >
> >
> > 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

Reply via email to