| Java FAQ | ||
| JSP FAQ | ||
| Servlet FAQ | ||
XyzWs JSP FAQ:
How to implement a thread-safe JSP page?
Printer-friendly version |
Mail this to a friend
|
Advertisement
|
How to implement a thread-safe JSP page?
A The JSP page by default is not thread safe, if you want to make it thread safe then you have add the following directive in your JSP page declaration: <%@ page isThreadSafe="false" %> With this, instead of a single instance of the servlet generated for your JSP page loaded in memory, you will have N instances of the servlet loaded and initialized, with the service method of each instance effectively synchronized. You can typically control the number of instances (N) that are instantiated for all servlets implementing SingleThreadModel through the admin screen for your JSP engine Whether your JSP is thread-safe or not is a consequence of the way you implemented your JSP. Strictly speaking you cannot change that simply by modifying an attribute. JSPs are normally perfectly thread-safe, since your run of the JSP does not hold any state (member variables).
For example, if you happen to use
If your JSP is not thread-safe you will have to add the
Note that even if the |