Solved

isThreadSafe

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
In this blog we highlight approaches to managed security as a service.  We also look into ConnectWise’s value in aiding MSPs’ security management and indicate why critical alerting is a necessary integration.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

691 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