tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: Null-pointer exception from response.encodeUrl under Windows Tomcat 7
Date Mon, 20 Jun 2011 21:29:28 GMT
Hash: SHA1


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
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla -


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

View raw message