Perfect!  Thanks Craig and Mike for your replies on this.
mark

> -----Original Message-----
> From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
> Sent: Friday, November 26, 1999 9:00 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Which Architecture..?
>
>
> Mike Engelhart wrote:
>
> > Mark Hayes wrote:
> > > Your views are valuable on this, thanks for sharing them.
>  I was further
> > > about the problem of passing information from the "logic"
> servlet to the JSP
> > > file to which it forwards.  If the servlet processes the
> business logic,
> > > many times data will result from that processing which
> then should be used
> > > in the presentation of the following JSP page.  Since
> there is no way to
> > > pass arguments when forwarding (right?), I assume you
> must use a session
> > > variable.  It seems that there are two cases; one case
> where the data being
> > > passed is meant to remain in the session, and another
> case where the data is
> > > only meant for the next page.  In the latter case, the
> JSP page should
> > > therefore delete the session data after it uses it.  I
> was wondering if you
> > > had run into this, and if a particular technique came in
> handy for you.
> > >
> > > thanks!
> > > mark
> >
> > You most definitely pass arguments to JSP's from a servlet
> (if you're using
> > the JSDK 2.1 or higher).   That's what the
> RequestDispatcher allows you to
> > do.  You do something like the following within the servlets
> > service/doGet/doPost method (of course you can stuff any
> object request with
> > setAttribute()):
> >
> > String myVar = "Testing";
> > request.setAttribute("myString", myVar);
> > rd =getServletContext().getRequestDispatcher("yourjsp.jsp");
> >  rd.forward(request, response);
> >
> > Mike
> >
>
> Mike's answer is right on the money ... request attributes
> were added to meet the
> exact need you are expressing.  I would only like to add that
> this "argument"
> shows up in your destination JSP page in a very convenient
> way -- as something you
> can reference with a <jsp:useBean> action:
>
>     <jsp:useBean id="myString" type="java.lang.String" />
>
> This also works for more complex object classes that have
> property getter methods
> in the usual JavaBeans naming convention.
>
> 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
>

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