Almost all the JSP file contains the page directive which gives the information to the JSP engine about the entire source file.
Syntax for writing page directives
<% page
[language=” java “]
[extends = “package.class”]
[import={package.class | package.*}]
[session=”true | false”]
[buffer=”none |8kb |sizekb”]
[autoflush=”true | false”]
[isThreadsafe=”true | false”]
[info=”text”]
[errorPage=”relative URL ”]
[contentType=”mimeType [;charset=characterset] “ | “text/html;charset=ISO-8859-1”]
[iserrorPage=”true | false”]
%>
Below are the attributes used in the page directives.
1. language=”java”
This specifies the scripting language used in the scriptlets,declarations, expressions in the JSP file. Java is the only allowed value.
2. extends=”package.class”
This will tell the JSP engine about the classes which are to be extended in the particular JSP page.
3. import=”package.class | package.*”
This attribute contains a list of java packages or classes that the JSP should import. More than one package can be imported by using comma separated list.
Below packages are implicitly imported in all the JSP page.
Java.lang.*
Javax.servlet.*
Javax.servlet.jsp.*
Javax.servlet.http.*
4. session=”true | false”
This attribute specifies whether the client must join as Http session in order to use the JSP page. If the value is true , the session object refers to the current or new session. The default value is true.
5. buffer=”none|8kb|sizekb”
This attribute specifies the buffer size in kilobytes used by the out object to handle output sent from the compiled JSP page to the client web browser. The default value is 8 kb . If you specify the buffer size,the output is buffered with the size specified .
6. autoFlush=”true|false”
This attribute specifies whether the buffered output should be flushed automatically when the buffer is full. The default value is true. If it is set to true the buffer will be flushed otherwise , an exception will be raised when the buffer overflows.
7. isThreadSafe=”true|false”
this attribute specifies whether the thread safety is implemented in the JSP file or not. The default value is true.which means the JSP container can send multiple, concurrent client request to the JSP page.
8. info=”text”
This specifies a text string that is incorporated into the compiled JSP page. This can be retrieved using the Servlet.getServletInfo() method.
9. errorPage=”relativeURL”
This attribute specifies the pathname to a JSP file to where it has to send the exception.
10. isErrorPage=”true|false”
this specifies the whether this JSP file display an error page. If set to true you can use the exception object in the JSP file . The default value is false.
11. contentType=”mimeType [;charset=characterset] “ | “text/html;charset=ISO-8859-1”
The default mime type is text/html and the default character set is ISO-8859-1.
Ashely Marr says
May 29, 2011 at 10:27 pmKeep posting stuff like this i really like it