Defines attributes that apply to an entire JSP page.
<%@ page [ language="
java" ]
[ extends="
package.class
" ]
[ import="{
package.class
|package.*
}, ..."
][ session="
true|false" ]
[ buffer="none|
8kb|size
kb" ]
[ autoFlush="
true|false" ]
[ isThreadSafe="
true|false" ]
[ info="
text
" ]
[ errorPage="
relativeURL
" ]
[ contentType="
mimeType
[ ; charset=
characterSet
]" |
"text/html ; charset=ISO-8859-1"
]
[ isErrorPage="true|
false" ]
[ pageEncoding="characterSet | ISO-8859-1" ]%>
<jsp:directive.pagepageDirectiveAttrList
/>
where pageDirectiveAttrList is the same as the list in the JSP syntax.
<%@ page import="java.util.*, java.lang.*" %> <%@ page buffer="5kb" autoFlush="false" %> <jsp:directive.page errorPage="error.jsp" />
The page directive applies to an entire JSP page and any of its static include files, which together are called a translation unit. A static include file is a file whose content becomes part of the calling JSP page. The page directive does not apply to any dynamic resources; see <jsp:include> for more information.
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 a page directive with import
more than once in a JSP page or translation unit.
No matter where you position the page directive in a JSP page or included files, it applies to the entire translation unit. However, it is often good programming style to place it at the top of the JSP page.
language="
java"
java
.
extends="
package.class
"
import="{
package.class
|
package.*
}, ..."
import
or you can use import
more than once in a JSP page.
import
attribute:
java.lang.*
javax.servlet.*
javax.servlet.jsp.*
javax.servlet.http.*
import
attribute before the element that calls the imported class.
session="
true|false"
true
, the session
object refers to the current or new session.
false
, you cannot use the session
object or a <jsp:useBean>
element with scope=session
in the JSP page. Either of these usages would cause a translation-time error.
true
.
buffer="none|
8kb|
sizekb"
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.
autoFlush="
true|false"
true
(the default value), the buffer will be flushed. If set to false
, an exception will be raised when the buffer overflows. You cannot set autoFlush
to false
when buffer
is set to none
.
isThreadSafe="
true|
false
"
true
, which means that the JSP container can send multiple, concurrent client requests to the JSP page. You must write code in the JSP page to synchronize the multiple client threads. If you use false
, the JSP container sends client requests one at a time to the JSP page.
info="
text
"
Servlet.getServletInfo()
method.
errorPage="
relativeURL
"
isErrorPage="true|
false"
true
, you can use the exception
object in the JSP page. If set to false
(the default value), you cannot use the exception
object in the JSP page.
contentType="
mimeType
[; charset=
characterSet
]" |
"
text/html;charset=ISO-8859-1"
text/html
, and the default character set is ISO-8859-1
.
pageEncoding="
characterSet
|
ISO-8859-1"
If you need to include a long list of packages or classes in more than one JSP page, you can create a separate JSP page with a page directive that contains the import list and include that file in the main JSP page.