Solved

isThreadSafe

Posted on 2004-03-22
5
790 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
5 Comments
 
LVL 9

Accepted Solution

by:
Nick_72 earned 150 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 150 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

813 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now