Solved

isThreadSafe

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

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
web service Rest Client creation 4 98
jersey maven project error 7 145
java operators 3 125
jsp login check 12 53
This article summaries thoughts and ideas from two years of sustained use. It provides good reasoning to make the jump to Windows 10.
In order to fulfill our mission of inspiring learning in the technology community, Experts Exchange is launching a Course of the Month program. Premium and Team Account members will have access to one course per month as a part of their membership, …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

749 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