Solved

isThreadSafe

Posted on 2004-03-22
5
786 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
What is Backup? Backup software creates one or more copies of the data on your digital devices in case your original data is lost or damaged. Different backup solutions protect different kinds of data and different combinations of devices. For e…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

706 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

19 Experts available now in Live!

Get 1:1 Help Now