The page Directive in JSP

By: Sathya Narayana Emailed: 1728 times Printed: 2337 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

The page directive specifies attributes for the page; all the attributes are optional, and the essential ones have default values, shown in bold:

<%@ page language="java"
          import="package.class, package.*, ..."
          info="Sample JSP to show tags"
          isErrorPage="true|false "
                        TYPE; charset=CHARSET|
                        text/html; charset=ISO-8859-1"

Bear the following in mind when using this directive:

  • The default buffer size is defined to be at least 8 kilobytes (KB).

  • The errorPage attribute contains the relative URL for the error page to which this page should go if there's an unhandled error on this page.

  • The specified error page file must declare isErrorPage="true" to have access to the Exception object.

  • The contentType attribute sets the MIME type and the character set for the response. The default value is "text/html" for standard JSP pages and "text/xml" when implementing JSP documents in Extensible Markup Language (XML) format.

  • The pageEncoding attribute defines the character encoding for the JSP page. The default is that specified in the contentType attribute or "ISO-8859-1" if none was specified there.

This is an example of the code that may be used for an error page:

<%@ page language="java"
          isErrorPage="true" %>

    <!-- This displays the fully-qualified name of the exception
         and its message-->
    <%= exception.toString() %>

    <!-- This displays the exception's descriptive message -->
    <%= exception.getMessage() %>

The page will print the error message received.

This directive can also switch on support for scripting and EL in the JSP document, using the isELIgnored attribute, which sets Expression Language (EL) support. Settings in web.xml may influence the behavior of this attribute. For this attribute, a value of true enables support, and false disables it. The default value is true.

JSP Home | All JSP Tutorials | Latest JSP Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.

Bookmark and Share


Be the first one to add a comment

Your name (required):

Your email(required, will not be shown to the public):

Your sites URL (optional):

Your comments:

More Tutorials by Sathya Narayana
Querying Data with the JSTL in JSP
Deleting Data in MySQL
Modifying data and using WHERE clause in MySQL
Querying the Database in MySQL
Inserting Data into Tables in MySQL
Changing the Structure of an Existing Table in MySQL
The Exception Object in JSP
The Application Object in JSP
The Session Object in JSP
The Out Object in JSP
The Response Object in JSP
The Request Object in JSP
Tag Libraries in JSP
Scriptlets and Expressions in JSP
Declarations in JSP

More Tutorials in JSP
LifecycleException: service.getName(): "Catalina"; Protocol handler start failed: ` Permission denied <null>:80
JSP Alert Example
JSP CheckBox Example
Uploading an Image to a Database using JSP
Uploading a file to a server using JSP
A JSP page that gets properties from a bean
The page Directive in JSP
The taglib, tag, include, attribute and the variable Directive in JSP
Declarations in JSP
Scriptlets and Expressions in JSP
Tag Libraries in JSP
The Request Object in JSP
The Response Object in JSP
The Out Object in JSP
The Session Object in JSP

More Latest News
Most Viewed Articles (in JSP )
JSP Example to connect to MS SQL database and retrieve records
What are the different scopes in JSP?
JSP CheckBox Example
Sending Email using JSP
JSP Alert Example
Click to Activate and Use this control
The JSP Program running first Time.
Syntax For JSP Declaratives
Tags using in jsp
JSP pages in servlet
Form processing in JSP
JSP Program for display Date
A Simple Servlet Generating Plain Text
The Servlet Life Cycle
Most Emailed Articles (in JSP)
Sending Email using JSP
The Servlet Life Cycle
Select Object
Embedding a QuickTime movie in a JSP
Embedding MP3 audio file in a JSP
Querying Data with the JSTL in JSP
Combining Scriptlets with HTML
JSP Directives
Form processing in JSP
JSP Program for display Date
An Example Using Servlet Initialization and Page Modification Dates
WebClient: Talking to Web Servers Interactively
Checkbox Object
Handling Events Connection refused: connect