What is Page Directive?

Used to define attributes of jsp page, such as character encoding, content type, import etc.
<%@page attribute1=” ” attribute2=””%>
The attributes of page directive,

Used to import a package.
<%@page import=”java.util.Date”%>
<%@page import=”java.util.*,javax.io.*”%>
Use comma to separate the packages. The quotes go around the entire list of packages. There is no semicolon in the end.
It tells the container whether the page is thread safe with proper synchronization implemented on the page. In other words whether the generated servlet needs to implement SingleThreadModel.
<%@page isThreadSafe=”false”%>
The value true means container can send multiple requests to the page. Here the value is set to false, that means the generated servlet implement the SingleThreadModel.
The default value is true.
Defines the MIME type and extra character encoding for the jsp response.
The default value is “text/html”
<%@page contentType=”text/html;charset=UTF-8”%>
Defines whether expression language are ignored when the page is translated.
The default it is false.
Difines whether the current page represents another jsp’s error page. By default the value is false. If the value set to “true” then page has access to the implicit exception object(which is an implicit object of Throwable), if false the implicit exception object is not available to the jsp page.
Defines an URL to the resource to which uncaught exceptions should be sent. The target URL must be error page(isErrorPage=”true”).
<%@page errorPage=”error.jsp”%>
Defines the scripting language used in scriptlets, expressions and declarations. The default value is java.
Define a fully classified class name of the super class that the jsp will extend to generate translated page.
Defines whether the page will participate in the HTTP session. If the value is set to true then the page can have access to the implicit session object. The default value is true.
Defines how buffering is handled by the out object(reference to JspWriter).
The default value is 8(kb). Output is buffered with a buffer size that is not less than the size specified.
Defines whether the buffered output is flushed automatically. The default value is true.
Used to set an information string that is incorporated into the page and accessable by using the Servlet.getServletInfo() method.
<%@page info=”this is the login jsp”%>
Defines the character encoding for jsp. The default value is “ISO-8859-1” unless the content type defines the encoding or the page uses XML document syntax.

<%@page contentType=”text/html;charset=UTF-8”
Session=”true” buffer=”16kb” autoFlush=”true”
isErrorPage=”false” isThreadSafe=”true”
info=”this is a page displays the date”
<%= “The current date is”+ new Date()%>

No comments:

Post a Comment