JSP Page Directive

Here we explain the page directive of jsp. Page directive has some attributes as language, extends, isThreadSafe, import, session, errorPage, isErrorPage and isELIgnored. The syntax of page directive as follows:

<%@page language=""
                 extends=""
                 isThreadSafe=""
                 import=""
                 session=""
                 errorPage=""
                 isErrorPage=""
                 isELIgnored=""
                                           %>

Now we explain each attribute of page directive as :

language: 
               Language attribute is used to specify the language for the scriptlets and declarations.
Currently valid value id java and is the default value.

Here see as example:

          <%@page language="java" %>

Extends:
                 HttpJspBase is the default super class in translated servlet in Tomcat.
If you want to use other super class for the translated servlet instead of HttpJspBase then use the extends.
For example as:


<%@page language="java" extends="javax.servlet.http.HttpServlet"%> 

isThreadSafe:

                        This attribute is used to specify the Servlet model required. Default Servlet model is multithred model. If you want to follow SingleThread model use this attribute value as false.


<%@page language="java" 
                extends="javax.servlet.http.HttpServlet"
                isThreadSafe="false"  %> 
import:
             Import attribute is used to specify the package to be imported for the translated Servlet.
Using this attributes, you can specify one or more package with common(,) separator.

Example as:
<%@import ="java.util.*",java.io.*%>

 
Session:
             Session attribute is used to disable session object in the jsp.
By default session object is enabled in jsp if you to disable use followin:

<%@session="false"%> 

isErrorPage:
                     When we want to centralize error in jsp then we can use isErrorPage attribute and give the value as true.
Here see the syntax:

<%@page isErrorPage="true"%>  

 isELIgnored:
                      This attribute is used to enable or dissable the EL expression.

0 comments :

Post a Comment