You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ja...@cardsetc.com on 2000/04/17 08:24:41 UTC

Saving ServletRequest's...

Folks,

A general servlet programming question, rather than one directed
specifically at Tomcat (are such questions considered wildly offtopic for
this list?).

Would anyone consider it unwise to write a web application that saved the
last HttpServletRequest object received by a servlet in the user's session,
and referred to it in the next request from the client?

Regards,
James W.

--------------------------------------------------------------------------
Cards etc will be on stand 1161 at CardTech SecurTech in Miami
from 2nd May to 4th May. Look forward to seeing you there!
--------------------------------------------------------------------------
This e-mail is from Cards Etc Pty Ltd (ACN: 069 533 302). It may contain
privileged and confidential information. It is intended for the named
recipient(s) only. If you are not an intended recipient, please notify us
immediately by reply e-mail or by phone on +61 2 9212 7773 & delete this
e-mail from your system.
--------------------------------------------------------------------------



Re: Saving ServletRequest's...

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
JamesW@cardsetc.com wrote:

> Folks,
>
> A general servlet programming question, rather than one directed
> specifically at Tomcat (are such questions considered wildly offtopic for
> this list?).
>
> Would anyone consider it unwise to write a web application that saved the
> last HttpServletRequest object received by a servlet in the user's session,
> and referred to it in the next request from the client?
>

Saving the request object is certainly possible, but it is not going to
do what
you want.  Most servlet containers recycle their request and response
objects
(to avoid creating them every time) on subsequent requests, so the
headers,
parameters, and attributes of that original header are going to get
changed
anyway.  In addition, there's no guarantee that the "next" request which
uses
your request object even comes from the same user, so you're going to
end up
scrambling things for all users.

The rule of thumb to always follow:  if you want to save anything from
one
request to the next, save those values individually (or in beans) in the
user's
session.

>
> Regards,
> James W.

Craig McClanahan