Scott Sanders wrote:

> > Thanks. I found the documentation regarding RequestDispatcher. But how
> > will I pass a data object to the second servlet since the include
> > and forward functions only has ServletRequest and ServletResponse
> > as parameters? My first servlet would like to process some of the
> > data and send the resulting data object to the second servlet.
> > Any suggestions? Thanks.
>
> Why not add it as a session object?
>
> Scott
>

You can also use request.setAttribute() in the first servlet to store objects
in this request, and request.getAttribute() in the second servlet to retrieve
them.  This is particularly useful if you do not need these objects after
finishing the current request, because they will get thrown away for you.  The
session approach is better if you need to keep them after you are through with
the current request.

NOTE:  request attributes were added in the 2.1 version of the servlet API.
If you're using a servlet engine based on a previous version of the API, this
won't work.

Craig McClanahan

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to