SERVLET.STM
Do not use 'SingleThreadModel' in Servlet class
Description
This rule flags servlet classes that use SingleThreadModel.
SingleThreadModel is a tag interface that a servlet can implement to transfer its re-entrancy problem to the servlet engine. As such, javax.servlet.SingleThreadModel is part of the J2EE specification. The WebSphere servlet engine handles the servlet's re-entrancy problem by creating separate servlet instances for each user. Because this causes a great amount of system overhead, SingleThreadModel should be avoided.
Example
package SERVLET;
import javax.servlet.*;
import javax.servlet.http.*;
public class STM extends HttpServlet implements SingleThreadModel {
// some code.
}
Repair
Developers typically use javax.servlet.SingleThreadModel to protect updatable servlet instances in a multithreaded environment. A better approach is to avoid using servlet instance variables that are updated from the servlet's service method.
Reference
IBM WebSphere Application Server Standard and Advanced Editions, Harvey W. Gunther.
http://www-4.ibm.com/software/webservers/appserv/ws_bestpractices.pdf
|