Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How can a thread safe JSP page be implemented?

user-image
Question added by Mohd Nadeem Mohd Rehman Mohammed , Software Engineer , Softworx Technologies
Date Posted: 2016/10/05

To make your JSPs thread-safe, you can implement the SingleThreadModel interface that prevents two threads from accessing the service method at the same time.

HAALIN IMRAN
by HAALIN IMRAN , System Administrator , SUPREME AUTO GROUP

A Java Server pages can be indicated as threadsafe through the isThreadSafe page directive attribute. Setting a value of false, will get the container to synchronize access to page level objects (and not to session and application scoped objects or objects of any other variety). Sometimes, it is still the responsibility of the developer to ensure that synchronous access to thread unsafe regions of code.

Evermore, the SingleThreadModel interface has also been deprecated in the Servlet Specification release 2.4. The SingleThreadModel interface is used to implement the supposed thread safety in JSPs as well - generated servlet classes will implement the SingleThreadModel for JSPs that use the threadsafe attribute. The specification itself outlines why the interface is deprecated.

Sherif Sayed
by Sherif Sayed , Software Engineer , Digital Processing Systems

By implementing the following directive in the JSP page

 

<% "page isThreadSafe="false @%>

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.