I dont undertand why option 2.) Response Attribute is right.
Neither do I, since there are no such things as "response attributes"! I think this was a mistake in the question (perhaps that option was meant to fool you, and yet they accidentically gave it as a correct answer).
The only thread-safe scopes are request and page (for JSPs). Session and context attributes are by default not guarded against concurrent access, so synchronisation on the session or context objects is recommended when there is the possibility for a simultaneous multiple modification or concurrent retrieval and modification.
Charles Lyons (SCJP 1.4, April 2003; SCJP 5, Dec 2006; SCWCD 1.4b, April 2004)
Author of OCEJWCD Study Companion for Oracle Exam 1Z0-899 (ISBN 0955160340 / AmazonAmazon UK )
posted 13 years ago
Thanks for help Charles. I feel good with my preparations reading your reply.
You are considering Request Attribute as thred-safe. Though it sounds fesible, I think the request attributes are not thread safe, as there my be references to the attributes object through which we can make changes to the attribute object.
The request Object is thread-safe as they pass as the method parameters.
I agree with Narendra, this is what specifications says
SRV.184.108.40.206 Thread Safety Implementations of the request and response objects are not guaranteed to be thread safe. This means that they should only be used within the scope of the request handling thread. References to the request and response objects should not be given to objects executing in other threads as the resulting behavior may be nondeterministic. If the thread created by the application uses the container-managed objects, such as the request or response object, those objects must be accessed only within the servlet�s service life cycle and such thread itself should have a life cycle within the life cycle of the servlet�s service method because accessing those objects after the service method ends may cause undeterministic problems. Be aware that the request and response objects are not thread safe. If those objects were accessed in the multiple threads, the access should be synchronized or be done through the wrapper to add the thread safety, for instance, synchronizing the call of the methods to access the
, or using a local output stream for the response object within a thread.
Watchya got in that poodle gun? Anything for me? Or this tiny ad?