You mention the use of filters, which leads me to the question of where is it
safe to start using a request-scoped object stored in a ThreadLocal? Would
it be safe to use in a filter, listener, or only once request processing
gets to the servlet?

A different way of asking this question is where/when does Tomcat start the
Thread that handles a given request, and what is executed in the context of
that thread? (e.g. filters, listeners, other things, servlets of course)

Thanks.



Leon Rosenberg-3 wrote:
> 
> they are absolutely perfect to reduce parameter pumping through many
> layers of code. But you should set and reset them properly, best in a
> filter.
> 
> regards
> Leon
> 
> On 6/2/07, lightbulb432 <[EMAIL PROTECTED]> wrote:
>>
>> Are ThreadLocal variables safe to use with servlets? There are some cases
>> where it could really simplify my code if used correctly, but first I
>> want
>> to make sure there aren't any horrible problems with doing so. (I've read
>> that the implementation of ThreadLocals has gotten much better with the
>> last
>> few releases of Java.)
>>
>> Has anyone had experience using them successfully, or even
>> unsuccessfully?
>> If so, please share your insights.
>>
>> Thanks.
>> --
>> View this message in context:
>> http://www.nabble.com/Is-ThreadLocal-safe-to-use-in-servlets-tf3858168.html#a10930638
>> Sent from the Tomcat - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Is-ThreadLocal-safe-to-use-in-servlets-tf3858168.html#a11269789
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to