On Wed, 19 Dec 2001, Casey Bragg wrote:
> Date: Wed, 19 Dec 2001 16:24:17 -0600
> From: Casey Bragg <[EMAIL PROTECTED]>
> Reply-To: Tomcat Users List <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: Why do all requests have the same HttpRequestFacade
>
> Using Tomcat 4.0.1 latest release (nightly 12/18/01 build)...
>
> I'm trying to save each user's last request for later review.
>
> I'm capturing the request with a Request Filter (implements Filter).
>
> For example, I store the ServletRequest coming into the filter's doFilter
> method. This is actually an HttpRequestFacade object (i.e.
> org.apache.catalina.connector.HttpRequestFacade@21e554). I've noticed that
> this object pointer never changes for a given session (i.e. it remains
> 21e554 for subsequent requests by the given session). In addition, if I
> retrieve this stored request and execute its getRequestURI method, that
> method returns null. The getUserPrincipal returns null as well. Both are
> non null while the Filter stores the request (while not yet fully
> processed).
>
> Is this correct behavior? Is there a way to store the request such that its
> data remains intact even after the request has been fully processed?
You cannot assume that the same request object will be used for every
request -- that's just an artifact of the fact that you are not making
simultaneous requests in your tests.
The basic rule: it is not legal to reference anything in the
HttpServletRequest that the servlet container gives you after the
service() method of your servlet (and the doFilter() method of all your
Filters) has returned. Anything you need to save across requests *must*
be stored elsewhere (such as in session attributes).
>
> Thanks...
>
> ...Casey
Craig
--
To unsubscribe: <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>