tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike Curwen" <mi...@gb-im.com>
Subject RE: Servlet thread safety in Tomcat
Date Mon, 09 Feb 2004 18:27:17 GMT
The one thing that could be said (so far), is to ensure you are using
properly scoped variables.  Generally speaking, for servlets, that means
don't use something like the following:

public class myservlet extends HttpServlet {

   private String MyBadlyPlacedVariable = null;

   public void doGet() { // exceptions and parameters snipped for
brevity
      
        MyBadlyPlacedVariable =
request.getParameter("some_variable_used_later");
 
        // later on in the code, use "MyBadlyPlacedVariable"...
        // it probably contains a value you're not expecting!
   }
}


You'll for sure experince threading problems, and this is the most
likely cause of any class of problems that's generically described as:
"the data is actualy mixing up".

> 
> 
> >-----Original Message-----
> >From: kwirirai [mailto:kwirirai@designat7.co.zw]
> >Sent: Monday, February 09, 2004 12:48 PM
> >To: tomcat-user@jakarta.apache.org
> >Subject: Servlet thread safety in Tomcat
> >
> >Hi All
> >I am developing an application that uses JavaMail.What I am 
> concered is 
> >the issue of thread safety,and efficiency.My question is do 
> I need to 
> >employ synchronized blocks in my Servlet code or is there another way
> to
> >implement thread safety.I have been experimenting with the 
> application 
> >and I have seen that the data is actualy mixing up.I realy 
> need to now 
> >how Tomcat handles request and issues those request ,this is in 
> >connection with threading. I have thought about the single 
> thread model
> >  in my servlets but I think this is an inefficient method to use.
> >
> >Thanks
> >Kwiri
> >
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 
> 
> 
> This e-mail, including any attachments, is a confidential 
> business communication, and may contain information that is 
> confidential, proprietary and/or privileged.  This e-mail is 
> intended only for the individual(s) to whom it is addressed, 
> and may not be saved, copied, printed, disclosed or used by 
> anyone else.  If you are not the(an) intended recipient, 
> please immediately delete this e-mail from your computer 
> system and notify the sender.  Thank you.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message