JSP Page Directive for Translation Unit

Translation Unit Page Directive

The page directive applies to an entire JSP file and any static files it includes with the Include Directive or
<jsp:include>
, which together are called a translation unit. Note that the page directive does not apply to any dynamic included files. You can use the page directive more than once in a translation unit, but you can only use each attribute, except import, once. (Because the import attribute is similar to the import statement in the Java programming language, you can use it more than once, just as you would use multiple import commands in the Java programming language) No matter where you position the page directive in the JSP file or included files, it applies to the entire translation unit. However, it is usually good programming style to place it at the top of the file.

Attributes
1. language="java"
The scripting language used in scriptlets, declarations, and expressions in the JSP file and any included files. In JSP 1.0, the only allowed value is java.
2. extends="package.class"
The fully qualified name of the superclass of the Java class file this JSP file will be compiled to. Use this attribute cautiously, as it can limit the JSP engine’s ability to provide a specialized superclass that improves the quality of the compiled file.
3. import= "{ package.class | package.* }, ..."
A comma-separated list of one or more packages that the JSP file should be import. The packages (and their classes) are available to scriptlets, expressions, declarations, and tags within the JSP file. You must place the import attribute before the tag that calls the imported class. If you want to import more than one package, you can specify a comma-separated list after import or you can use import more than once in a JSP file.
4. session="true|false"
Whether the client must join an HTTP session in order to use the JSP page, If the value is true, the session object refers to the current or new session. If the value is false, you cannot use the session object in the JSP file. The default value is true.
5. buffer="none|8kb|sizekb"
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 8kb. If you specify a buffer size, the output is buffered with at least the size you specified.
6. autoFlush="true|false"
Whether the buffered output should be flushed automatically when the buffer is full, If true (the default value), means that the buffer will be flushed. If false, means that an exception will be raised when the buffer overflows. You cannot set autoFlush to false when the value of buffer is none.
7. isThreadSafe="true|false"
Whether thread safety is implemented in the JSP file. The default value is true, which means that the JSP engine can send multiple requests to the page concurrently, if you use true (the default value), multiple threads can access the JSP page, and you must synchronize them. If you use false, the JSP engine sends client requests one at a time to the JSP page.
8. info="text"
A text string that is incorporated verbatim in the compiled JSP page, You can later retrieve the string with the Servlet.getServletInfo() method.
9. errorPage="relativeURL"
A pathname to a JSP file that this JSP file sends exceptions to, If the pathname begins with a /, the path is relative to the JSP application’s document root directory and is resolved by the Web server. If not, the pathname is relative to the current JSP file.
10. isErrorPage="true|false"
Whether the JSP file displays an error page, If true, you can use the exception object, which contains a reference to the thrown exception, in the JSP file. If false (the default value), means that you cannot use the exception object in the JSP file.
11. contentType="mimeType [ ;charset=characterSet ]" |
"text/html;charset=ISO-8859-1"
The MIME type and character encoding the JSP file uses for the response it sends to the client. You can use any MIME type or character set that are valid for the JSP engine. The default MIME type is text/html, and the default character set is ISO-8859-1.


JSP Page Directive Syntax



<%@ 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="relativeURL" ]
[ contentType="mimeType [ ;charset=characterSet ]" |
"text/html ; charset=ISO-8859-1" ]
[ isErrorPage="true|false" ] %>


Examples
<%@ page import="java.util.*, java.lang.*" %>
<%@ page buffer="5kb" autoFlush="false" %>
<%@ page errorPage="error.jsp" %>


Related Topic JSP Variable Declaration Statement
How to Add Text File or Code in a JSP File at Translation Time
JSP Interview Questions & Answers
What is the Difference between i386 and x86-64
How to set the HTTP Cookie Values

nScraps.com © 2011   Privacy Policy  Terms of Service  Feedback