On Wed, 15 Jun 2011, Christopher Schultz wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jocelyn,

On 6/15/2011 1:43 PM, Jocelyn Ireson-Paine wrote:
     ResponseHolder rh = (ResponseHolder)this_session.getAttribute(
  "response_holder" );

Here is the beginning of your errors.

By saving a reference to the response that was used for your first page
access, you have set yourself up for errors for future responses, and
not just in the JSP at hand: you could potentially cause errors in the
responses of other requests down the line that re-use the response object.

That may sound entirely insane, and it kind of is, unless you understand
that Tomcat, in order to manage the application's heap more efficiently,
re-uses both HttpServletRequest and HttpServletResponse objects. ...

Christopher, and also Konstantin and Martin, thank you for your postings on this. As it happened, my original code that crashed, and from which I derived the demo code that I posted, had a bug. I do put a reference to the response into an instance, in order that I can give my main processing method all the data it needs (including the response) as one single parameter. But I'd intended to put the response into this instance every time my JSP is accessed, and not merely the first time. Until you pointed it out, I didn't notice that I wasn't, even with my simplified code. So thanks for that.

That said, I think I was expecting that it wouldn't matter, since the response "ought" to be the same instance on each processing cycle anyway. It's interesting to see why Tomcat violates the principle of least surprise - and I see it's still being discussed...

Jocelyn


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to