JSP Page Directive
In this JSP tutorial, you will learn about JSP page directive, attributes of the page directive along with syntax, examples and explanations.
autoFlush:
autoFlush attribute is used to specify whether or not to automatically flush out the output buffer when it is full. Syntax of autoFlush attribute available for page directive is written as:
<%@ page autoFlush = "true|false" %>
In the above example, page and autoFlush are keywords. True or false value can be set to autoFlush attribute, by default, its value is true . This means, the buffer will be flushed automatically when it is full. When the autoflush attribute is set to false, then an exception is thrown when the output buffer gets full and results in overflow.
NOTE: The user should not to set the autoflush to false when the buffer attribute is set to none.
isThreadSafe:
isThreadSafe attribute is used to set whether the generated Servlet handles multiple requests or single requests, depending on the set value of true or false. isThreadSafe attribute is used to set and ensure whether thread safety is implemented in the JSP page.
Syntax of isThreadSafe attribute available for page directive is:
<%@ page isThreadSafe="true|false" %>
In the above statement, page and isThreadSafe are keywords. A true or false value can be set and, by default, the value is set to true. It implies that the JSP container can handle or send multiple concurrent client requests to the JSP page by starting a new thread. If the value of this attribute is set to false, then the JSP container sends client requests only one at a time to the JSP page.
info:
Programmers make use of info attribute to place the information or documentation for a page. Details such as: author, version, copyright and date are placed in this attribute. This is actually text string that is written as input text in the compiled JSP page.
Syntax of info attribute available for page directive is:
<%@ page info = "text" %>
In the above statement, page and info are keywords. The details of documentation or information are placed inside " ". This is actually text string written as input text in the compiled JSP page.
For example:
<%@ page info = "exforsys.com example,2006" %>
The above text, exforsys.com example, 2006, is a text string written as text in the compiled JSP page.
errorPage:
If the programmer wants to place errors in a different page then the URL to the error page can be mentioned in this attribute as errorPage.
Syntax of errorPage attribute available for page directive is as below:
<%@ page errorPage = "relativeURL" %>
In the above statement, page and errorPage are keywords.
For example, the user specifies the attribute errorpage is:
<%@ page errorPage = "/handleerr/testerr.jsp" %>
isErrorPage:
isErrorPage attribute is used to specify whether or not a JSP page displays an error page by setting the value as true or false. By default, the value is set to false, meaning that the user cannot make use of the exception object in the JSP page. If the value is set to true, then it means that the user can make use of the exception object in the JSP page.
Syntax of isErrorPage attribute available for page directive is:
<%@ page isErrorPage="true|false" %>
In the above statement, page and isErrorPage are keywords. By default, the value is false.
contentType:
contentType attribute is used to set the mime type and character set of the JSP. The user can make use of any MIME type or character set valid for the JSP container.
Syntax of contentType attribute available for page directive is:
<%@ page contentType="mimeType [; charset=characterSet]" %>
In the above statement, page and contentType are keywords. The default, MIMEtype is text/html, and the default character set is ISO-8859-1.
For example, the user specifies the attribute contentType is:
<%@ page contentType="text/html;charset=ISO-8859-1" %>