Friday, 28 February 2014

How to implement thread-safe JSP page?

Implement SingleThreadModel interface by adding the directive <%@ page isThreadSafe="false" %> within JSP page. Now N instances of the servlet loaded and initialized rather than single instance of the for your JSP page loaded in memory. Service method of each instance will be synchronized.

Number of instances that are instantiated for all servlets can be controlled. Avoid using the TAG for variables and set isThreadSafe to true.
SingleThreadModel is not recommended for normal use; rather make them THREAD SAFE like old ways.

No comments:

Post a Comment

Thank you so much for providing your valuable feedback. I will will look into them and update my skills & technologies accordingly.