File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Are implicit objects in JSP are thread safe??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Are implicit objects in JSP are thread safe???" Watch "Are implicit objects in JSP are thread safe???" New topic
Author

Are implicit objects in JSP are thread safe???

Murali Mohan
Ranch Hand

Joined: Jun 14, 2001
Posts: 47
Hi all,

Are implicit objects in JSP are thread safe???
Thanks,
Mohan
[ January 30, 2004: Message edited by: Murali Mohan ]
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Depends. For example the request, response and exception objects are created for the current thread and therefore they are safe. The application and session objects can be accessed by several threads and therefore not thread safe.
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
Session scope - Not thread safe
Context scope - Not thread safe
Request scope - thread safe (Only one thread per request)


I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
It's important to note, though, that if you store objects in the application, session, request or page contexts, they are not guaranteed to be thread safe.
Although the request and page objects themselves are threadsafe, objects stored in them are only safe if they are not also used by other threads. Remember that one of these contexts only stores a reference to an object, not a separate copy of it.
I hope that's not too confusing.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
bharat nagpal
Ranch Hand

Joined: Oct 26, 2002
Posts: 76
Frank,
Could you please explain in detail?
TIA
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
I'll try.
If you create a completely new object in the method, and place it in the request context, it will be threadsafe:

If you use an existing object which is also present in one of the unsafe contexts (application or session), it will not be threadsafe:

If you use an existing object which is a static (class) or member (instance) variable in the servlet class, it will not be threadsafe:

Is that any clearer?
bharat nagpal
Ranch Hand

Joined: Oct 26, 2002
Posts: 76
yup.Thats very much clear now.
Thanks a lot
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Are implicit objects in JSP are thread safe???
 
Similar Threads
Implicit Objects doubt!
true or false......implicit obj's threadsafe?
Implicit and Explicit Objects
Is Implicit objects are thread safe?
Difference between page , pagecontext and application implicit object