[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

isThreadSafe

Posted on 2004-03-22
5
Medium Priority
?
796 Views
Last Modified: 2007-11-27
Hi,

  When isThreadSafe = "false" should be used in a JSP Page ?

i'm doing some database operations by calling a Stored Procedure in JSP Page...
What is the efficient way to ensure that my Jsp Page is Thread safe ?
 
Simply can i put isThreadSafe="false"
in all my Jsp pages.


Thanks in Advance,
Santhoshi
0
Comment
Question by:santhoshi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 9

Accepted Solution

by:
Nick_72 earned 600 total points
ID: 10648212
You don't have to do that. Every user that connects to a webserver recieves a session, and only the current user can access that session. Your jsp is compiled into a servlet by the servlet container (Catalina if you're using Tomcat) and every call to it gets a thread of it's own. Just make sure that you don't use global variables (or member variables if you wish to call them that) in the servlet (which is really only to have in mind if you're writing a servlet directly, not a jsp).
0
 

Author Comment

by:santhoshi
ID: 10648282
Actually I'm using Global Variables in my Jsp Page.
In this case how the request will be processed.
Each request will not get a thread of its own. Is it ?
0
 
LVL 7

Assisted Solution

by:searlas
searlas earned 600 total points
ID: 10648762
Putting isThreadSafe="false" in your JSP means that you are aware that there is
something inherently not thread safe in your JSP.  Simply adding that does not
magically make your JSP thread safe.  You still need to take care when using
statics and instance variables to ensure thread safety.  i.e. static variables
may still be accessed by mulitple threads at once; and any state you are
attempting to maintain in instance variables needs to be carefully considered
and probably exchanged for use of session's where appropriate.

i.e. static - never thread safe, no matter whether isThreadSafe is true or false:
<%! static List threadUnsafeList = new ArrayList(); %>

instances variables, thread safe only if isThreadSafe="false", but still need careful use:
<%! List threadsafeList = new ArrayList(); %>


0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An overview of cyber security, cyber crime, and personal protection against hackers. Includes a brief summary of the Equifax breach and why everyone should be aware of it. Other subjects include: how cyber security has failed to advance with technol…
With so many activities to perform, Exchange administrators are always busy in organizations. If everything, including Exchange Servers, Outlook clients, and Office 365 accounts work without any issues, they can sit and relax. But unfortunately, it…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question