-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Jocelyn,
On 6/20/2011 4:11 PM, Jocelyn Ireson-Paine wrote: > 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. No problem. If you need all your data from scratch, anyway, why bother caching anything at all? If your data is always ephemeral, these issues evaporate and your code (often) becomes cleaner, too. > 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. I would actually expect something different: that Tomcat always gives me a brand new, never-before-used and never-to-be-used-again object. The fact that Tomcat plays some tricks to reduce heap churn (that is, allocating/initing/deallocating lots of "temporary" objects) should be entirely transparent to the webapp if it's playing by the rules. The servlet spec clearly states that the request and response objects are only valid during a particular transaction. > It's interesting to see why Tomcat violates the principle of > least surprise - and I see it's still being discussed... Ignorance of the spec will certainly cause a lot of "surprises" :) I'm not convinced that this should be surprising, anyway. If I write a method like this: public void foo(Bar bar) { ... } Why should the method foo() expect that each invocation will always have the same Bar object passed-into it? By extension: public void doGet(HttpServletRequest req, HttpServletResponse rsp) { ... } Should this one be treated any differently? If the object is always going to be the same, why bother having it as a parameter instead of part of the object's state? - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk3/u7gACgkQ9CaO5/Lv0PBNzwCfY0SpILBVc49KPQn1gpjgVl2P 8YIAmwaX5CPtfQVdeicXoFW3j1B9tfwo =FL9q -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org