tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <Craig.McClana...@eng.sun.com>
Subject Re: When does an object die?
Date Thu, 28 Dec 2000 02:08:17 GMT
"David M. Holmes" wrote:

> OK I have a custom tag which passes the request object to a handler class, which is threaded,
to
> do some background processing. If the handler class is in the webapp\classes directory
it works
> fine. If it is in the system classpath I get NullPointerExceptions when trying to invoke
any
> method on the request object. Is the request object out of scope. Any help would be appreciated.
>

The request and response objects are only valid for the duration of the call to the servlet's
service() method.  Any attempt to reference them outside of that time frame (such as from
another
thread in your scenario) will result in undefined behavior.

The solution is to copy everything you need from the request object, while still inside the
service() method, into some private object of your own that is then referenced from the background
thread.

>
> Dave
>

Craig McClanahan



Mime
View raw message