SingleThreadModel

Servlet/JSP developers are sometimes confused by this interface - java.servlet.SingleThreadModel.

 

By default Web container assumes that all servlets and JSPs are thread-safe. As a servlet or JSP author, you need to ensure your servlet or JSP can achieve that. If not, you have to tell the Web container by implementing the SingleThreadModel or setting isThreadSafe="false". Web container may satisfy the requirement by serializing requests on an instance, or by maintaining a pool of instances.

 

If your servlet or JSP is badly written (e.g. accessing shared objects that are not properly synchronized), SingleThreadModel or isThreadSafe="false" won't help you much.

 

Please also note that in servlet 2.4 spec this interface has been deprecated.

 

The best practice is to always create a thread-safe servlet.