well.. thanks for all the responses. You guys are great. At least I am
learning a lot.

On the same thread, can I do something like this? When the user hits submit,
I am redirecting back to the same page, executes <jsp:setProperty, and then
forwarding to the Model2Servlet.

<jsp:useBean id="theAddressBean" scope="session"
class="CMBeans.CMAddressBean"/>

<jsp:setProperty name="theAddressBean" property="*"/>

<%
  if ( request.getParameter( "submit") != null )
  {
    <jsp:forward page="/servlet/Model2Servlet" />
     return;
  }
%>

<form action="thispage.jsp">  --> submit to itself
<input type=text name=userName>
<input type=password name=password>
<input type=submit name="submit" value="submit">
</form>

1. I want to use the best of JSP and Servlets. jsp:setProperty tag is very
useful when you have a page with considerable form input parameters. I don't
have to get all the parameters from the request object and then set to the
appropriate bean and then save to the session  object. If I have 20/30
pages, this can be a lot of code.

2. If I use the Servlet to do all the processing (Model2Servlet), if I ever
change my form input names, I have to change the servlet too. I don't see a
clear separation of presentation layer from the business logic layer. If we
use the jsp:setProperty tag, the change in form input names result a change
in the bean object only. Oh! well.. all the objects which use the bean too.
Not a whole lot of difference, but still. And, functionally the Beans act as
the agent/data Carriers between Servlets and JSPs.

3. Can I do something like this in the Model2Servlet?

     HttpSession session = request.getSession(true);
     UserInfoBean uib = (UserInfoBean) session.getValue("theUserInfoBean");
     if (uib == null)
         session.putValue("theUserInfoBean", uib);

    JspRuntimeLibrary.introspect( theAddressBean, request );

Thanks
Sree



>From: "Craig R. McClanahan" <[EMAIL PROTECTED]>
>Reply-To: "Craig R. McClanahan" <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Re: Model 2 Architecture and jsp:setProperty tag question
>Date: Wed, 2 Feb 2000 17:29:40 -0800
>
>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

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

===========================================================================
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