aspose file tools*
The moose likes JSP and the fly likes Is JSP thread safe? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Is JSP thread safe?" Watch "Is JSP thread safe?" New topic
Author

Is JSP thread safe?

Shruti Sharma
Ranch Hand

Joined: Mar 25, 2010
Posts: 55
Hi,

I understand that servlet is multithreaded and not thread safe. How about a JSP? Is JSP thread safe by default?

The JSP page directive isThreadSafe is true by default which means that JSP should be thread safe. But every JSP gets translated to a servlet, so that should mean that JSP is not thread-safe. Is it not contradictory? I am confused about this concept.
Please help.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61201
    
  66

"Ss Sharma", please check your private messages for an important administrative matter. Again.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61201
    
  66

Ss Sharma wrote:Is JSP thread safe by default?

As asked, this question makes no sense. It's like asking "Are Java methods thread safe?"

And the answer is "It depends what you do in them."

The JSP page directive isThreadSafe is true by default which means that JSP should be thread safe.

That directive does not make a JSP thread-safe. It's meant for you to tell the JSP engine whether the JSP is thread-safe or not.

If you use Java scriptlets in a JSP ( in 2010? I would hope not!) it's easy to make a JSP non-thread-safe. Especially if you use scriptlet declarations (Again, ).

Also, modifying values stored in the session and application scopes can create thread-safety issues.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is JSP thread safe?