Explain how to implement a thread-safe JSP page?
JSPs can be made thread-safe by having them implement the SingleThreadModel interface by using <%@ page isThreadSafe="false" %> directive in the page.
By doing this, one will have multiple number of instances (say N) of the servlet loaded and initialized, with the service method of each instance effectively synchronized.
SingleThreadModel is not recommended for normal use as there are many pitfalls. Hence one should try the old fashioned way, which is making them thread safe.
Explain how to implement a thread-safe JSP page.
A JSP can be thread safe by implementing SingleThreadModel interface. This process can be done by having the following tag in a JSP:
<%@ page isThreadSafe="false" % >
within your JSP page.