tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Barker" <>
Subject Re: is it possible to use setAttribute for request in jsp??
Date Fri, 21 Feb 2003 07:52:50 GMT

"Erik Price" <> wrote in message
> Ashish Kulkarni wrote:
> > Hi Filip,
> >
> > I know, but i want to achieve some thing like
> > reqeust.setAttribute(), i dont want to save the object
> > in session, as then i will have to put some logic to
> > get it out of session, or size of session will go on
> > increasing, and will create problem in future
> Setting an attribute in the request with request.setAttribute() will
> only persist for the lifetime of the request.  Which means that you
> cannot submit to a form (this causes a new HTTP request).
> In theory you could call RequestDispatcher.forward() on a new JSP page
> and that attribute /should/ persist, but that is not the same as
> submitting a form.

Actually, this is the crucial difference.  If you set the Attribute on the
Request, then it can be seen by any rd.forward/include.  If you set it on
the Page, it can't.  In either case, it won't persist across requests.  The
only way to do that is to set it on the Session.  If you don't totally abuse
this feature, then the memory gets returned to the JVM once the session
times out.

> Erik

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message