This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JSP and the fly likes isThreadSafe Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "isThreadSafe" Watch "isThreadSafe" New topic
Author

isThreadSafe

Ashimashi Kabashi
Ranch Hand

Joined: Sep 11, 2006
Posts: 84
Hello all

I am using the page directive to set the page to threadsafe i.e.


I am assuming that if more than two threads (i.e. if this page is requested by more than two clients) at the same time, the page will throw an exception.

But my page is does not do anything (no exceptions) if more than two clients access it.

Any help will be appreciated
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

"Thread safe" means it is safe for more than one thread to access the JSP at a time. So I can't imagine why you would expect an exception to occur if more than one thread accesses the JSP at the same time. Basically, your assumption doesn't make any sense.
Gopikrishna Madishetti
Greenhorn

Joined: Sep 30, 2008
Posts: 10
isThreadSafe attribute -- this support the facility of maintaining thread for sending multiple and concurrent requests from the JSP container to the JSP page if you specify the true value of the attribute otherwise if you specify the false value of the attribute then the JSP container can send only one request at one time.
Ashimashi Kabashi
Ranch Hand

Joined: Sep 11, 2006
Posts: 84
hmm..

So I am guessing is.. how is the page ThreadSafe? does the isThreadSafe method make the PAGE threadsafe?

I mean.. how can I see the utility of this directive?

Thanks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Of course, just saying that a class is thread safe doesn't make it thread safe. However, if you declare that your JSP is not thread safe, then the container will believe you and not let two threads use it at the same time. And if you declare that it is thread safe, then the container will allow more than one thread to use it at the same time. In this case, bad things may happen if it is really not thread safe.

However, writing JSP code which is not thread safe is a bad practice anyway, so there should be no point in ever using this attribute. The question is purely theoretical.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: isThreadSafe