File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Response and Request Object threadsafe? Why? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Response and Request Object threadsafe? Why?" Watch "Response and Request Object threadsafe? Why?" New topic
Author

Response and Request Object threadsafe? Why?

Louis Duquesne
Greenhorn

Joined: Mar 18, 2002
Posts: 1
According to two questions in the "WGS-PREX-J080B: ePractice Exam Sun[TM] Certified Web Component Developer J2EE" (Objective 7), the Response object is not thread-safe.
I fail to understand why (isn't this a parameter and thus a "local" variable?).
Would someone care to explain? Is the Request object thread-safe, if so why the difference?
Thanks
Louis


.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

It is a local variable, but check out what the Servlet specification has to say about these objects:
SRV.2.3.3.3 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 must not be given to objects
executing in other threads as the resulting behavior may be nondeterministic.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Duquesne,

Take another glance at our naming policy ( http://www.javaranch.com/name.jsp ), and update your display name (or re-register).

Thanks, and welcome to JavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Response and Request Object threadsafe? Why?
 
Similar Threads
Is session object thread safe.
Is request and resonse objects are thread safe?
request and response(Thread safe--?)
Thread Safe
ThreadSafety of HttpServletRequest & HttpServletResponse objects