Yes you may get into trouble! You can have trouble not only with static,it`s even worse than that. This is based on the fact that ONLY ONE object of your servlet class will be created in the container. That means that even member fields of your servlet class are somehow "static". Each user request may have it`s own thread and therefore it`s own stack. So there is no problem with method-parameters and method-local variables. On the other hand two concurrent user request on the same servlet (without "threadsafe" => two concurrent threads) access the very same static/member fields. This could lead to a situation where user A overwrites values of static/member fields which user B has lately set and relys on. But user B may end up in unexpected behaviour because he/she is using A`s values. CONCLUSION: Avoid any static/member field in cases you have to store state per user request. Use Session object instead.
peter ----- Original Message ----- From: Mukul Singh <[EMAIL PROTECTED]> Date: Thursday, October 18, 2001 6:24 am Subject: Static variables and Thread safety > Hi, > > If a servlet calls a static method in another class, supposing > that the > class on which we are invoking the method has got static variables > which are > modified by the call to the method in the class. Will this kind of > scenariolead to some inconsistent results if the servlet does not > implement the > SingleThreadModel? > > Thanks, > > MS > > ________________________________________________________________________ ___ > To unsubscribe, send email to [EMAIL PROTECTED] and include in > the body > of the message "signoff SERVLET-INTEREST". > > Archives: http: > Resources: http://java.sun.com/products/servlet/external- > resources.htmlLISTSERV Help: > http://www.lsoft.com/manuals/user/user.html > ___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html