The page Directive in JSP

By: Sathya Narayana Emailed: 1589 times Printed: 2039 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"
          extends="package.class"
          import="package.class, package.*, ..."
          session="true|false"
          buffer="none|default|sizekb"
          autoFlush="true|false"
          isThreadSafe="true|false"
          info="Sample JSP to show tags"
          isErrorPage="true|false "
          errorPage="ErrorPage.jsp"
          contentType="TYPE|
                        TYPE; charset=CHARSET|
                        text/html; charset=ISO-8859-1"
          pageEncoding="default"
          isELIgnored="true|false"
%>

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" %>

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

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

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

Comments(0)


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: `java.net.BindException: 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 Alert Example
JSP CheckBox Example
Comparison operators in JSP
JSP Program for display Date
Uploading a file to a server using JSP
The Advantages of JSP
Uploading an Image to a Database using JSP
Sending Email using JSP
Writing your first JSP page
Getting Started with JSP
Arithmetic Evaluation Using the Expression Language in JSP
The BodyTag Interface in JSP
JSP Tags for SQL to connect to a database
Most Emailed Articles (in JSP)
Click to Activate and Use this control
HttpClient
NotifyUtil::java.net.ConnectException: Connection refused: connect
Comparison operators in JSP
Document Object
Embedding java codes in jsp sciptlets
Form processing in JSP
JSP Program for display Date
The Servlet Life Cycle
Enable/Disable Scripting Elements in JSP
Steps to get a Free SSL certificate for your Tomcat
Cookies using JSP or Java Bean
The JSP Program running first Time.
JSP pages in servlet
Sessions in JSP