tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Crowther" <>
Subject RE: Is there an easy way to replace http-processor threads?
Date Fri, 21 Jul 2006 10:30:04 GMT
> From: Leon Rosenberg [] 
> Now I have the unpleasant
> situation that i need some information pretty deep in some use cases
> of the application (like current locale) which I only have at the top
> (servlet) level.

We had the same issue with an app.  Provided you remember that Tomcat
re-uses threads, this isn't actually that much of a problem if all of
your processing is done on the request's thread.  Simply use a global
class with a ThreadLocal
instance variable holding your extra data.  Because of re-use, remember
to nil the variable at the start of your processing, possibly even in a
Filter if you're feeling paranoid.

We took that approach.  I'll be interested to hear of any others.

		- Peter

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message