Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

How can a thread safe JSP page be implemented?

user-image
Question ajoutée par Mohd Nadeem Mohd Rehman Mohammed , Software Engineer , Softworx Technologies
Date de publication: 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
par 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
par Sherif Sayed , Software Engineer , Digital Processing Systems

By implementing the following directive in the JSP page

 

<% "page isThreadSafe="false @%>

More Questions Like This

Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?