The "isThreadSafe" & "info" Attribute of JSP page directive


 

The "isThreadSafe" & "info" Attribute of JSP page directive

In this section, we will learn about "isThreadSafe" & "info "attribute of JSP page directive

In this section, we will learn about "isThreadSafe" & "info "attribute of JSP page directive

The "isThreadSafe" & "info" Attribute of JSP page directive

In this section, we will learn about "isThreadSafe" & "info "attribute of JSP page directive.

The "isThreadSafe" attribute of JSP page Directive

  This attribute tells us whether thread safety is implemented in JSP file or not. The Syntax of the "isThreadSafe" page directive is :

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

The default value is "True" ,If the value is set to "True", the web container can send multiple concurrent  client requests to the JSP page. If you set value to "True", You must ensure that shared object's access must be properly synchronized at the page level. This includes objects created within declarations, JavaBeans components with page scope, and attributes of the page context object(ex. session ,request etc) .

If the value is set to "false", the web container sends single request at a time , in the order they were received and access to page-level objects does not have to be controlled. Furthermore, it is not recommended to set "isThreadSafe" to false. The JSP page?s generated servlet will implement the "javax.servlet.SingleThreadModel" interface, and because the "Servlet 2.4" specification disapproves  "SingleThreadModel", the generated servlet will contain disapproved code.

The "info" attribute of JSP page directive

The "Info" attribute of JSP page Directive is used to include page information in the form of text or string. This string can be retrieved lately by using "Servlet.getServletInfo()" method. This feature is useful where a huge number of server programs are running on a server and you need to know about a particular servlet or JSP. You will get information of that JSP using "Servlet.getServletInfo()" method. The Syntax of the "isThreadSafe" page directive is :

     <%@page info="text" %>    

Example : <%@page info="This is the example of info attribute of the page directive." %>    

 

Ads