File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is JSP thread safe?

 
Shruti Sharma
Ranch Hand
Posts: 55
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Ss Sharma", please check your private messages for an important administrative matter. Again.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64196
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic