Advertisement



< Prev
Next >



JSP isThreadSafe Attribute



In JSP, the isThreadSafe attribute of page directive is used to indicate if your code is thread safe or not. The isThreadSafe attribute can be given either of the two boolean values: true or false.




Syntax of isThreadSafe:


<%@ page isThreadSafe = "true|false" %>





When the isThreadSafe attribute is assigned a false boolean value, the servlet resulting from the JSP page will implement the SingleThreadModel interface. It indicates that your code is not thread safe and hence it should not be concurrently accessed by multiple threads.


Advertisement




isThreadSafe example


In the upcoming example, we are setting the isThreadSafe attribute to false to indicate that our JSP page is not thread safe.

ThreadSafe.jsp
<!–– Example of isThreadSafe attribute of page directive of JSP -->

<html>

<head>
<title>JSP isThreadSafe Attribute</title>
</head>


<body>

<%@ page isThreadSafe = "false" %>

<b>Setting isThreadSafe attribute to false indicates that this JSP page is not thread safe 
and should not be concurrently accessed by multiple threads.</b>.

</body>

</html>



By executing the above mentioned JSP web page will indicate the container that JSP page is not thread safe.




Note


By default, the value of isThreadSafe Attribute is true, which indicates that your JSP web page is thread safe.




Please share this article -




< Prev
Next >
< JSP contentType Attribute
JSP session Attribute >



Advertisement

Please Subscribe

Please subscribe to our social media channels for daily updates.


Decodejava Facebook Page  DecodeJava Twitter Page Decodejava Google+ Page




Advertisement



Notifications



Please check our latest addition

C#, PYTHON and DJANGO


Advertisement