JSP Page Directive

JSP page directive provides various attributes with unique properties. These attributes can be applied to an entire JSP page. The syntax of Page directive is as follows: -

<@page attribute="value">

Page directive tag can be placed anywhere inside the JSP page but placing it as the first statement is more preferable.

Attributes of Page Directive

These are the following attributes of page directive: -

language

This attribute defines the scripting language used in JSP page. By default, Java is used as a scripting language.

Syntax: -

<@page language="Scripting-language">

contentType

In servlets, we required to set the type of content on response attribute.

response.setContentType("text/html");

Like servlets, JSP use contentType attribute to define MIME type and character set of the response message. The default expression is: -     

<@page contentType="text/html; charSet=UTF-8">

buffer

This attribute is use to buffer the response objects. Here, value represents the size of buffer. Instead of passing numeric value, it also allows to declare none. In this case, buffer uses its default size that is 8kb.

Syntax: -

<@page buffer="value">

info

In servlets, getServletInfo() method returns the information about the servlet. The similar role is played by info attribute in JSP. Hence, this attribute provides any type of description or information in a form of string.

Syntax: -

<@page info="value">

autoFlush

The purpose of this attribute is to flush the buffer automatically. For this, the value of autoFlush must be true.

Syntax: -

<@page autoFlush="true/false">

The default value of autoFlush is always true.

isThreadSafe

The role of isThreadSafe attribute is similar to SingleThreadModel interface in Servlet. Thus, it ensures that JSP handle only one type of request at a time.

Syntax: -

<@page isThreadSafe="true/false">

Here, the default value is true.

extends

The extends attribute inherits the superclass to serve its properties in current class. It is similar to extends keyword in Java.

<@page extends="package.class">

import

This attribute is used to import packages in JSP page. The package consists of similar type of classes and interfaces. It is similar to import keyword in Java.

<@page import="package-name">

session

Sessions are used to recognize the user. By default, the value of session is true in JSP. Hence, JSP always establish a session unless we make the value false.

<@page session="true/false">

errorPage

This attribute redirects the current page to JSP exception page if any exception occurs.

Syntax: -

<@page errorPage="value">

Here, URL of JSP exception page is passed.

isErrorPage

This attribute specifies that the current JSP page contain an error page. This error page can be utilized only when exception occur.

Syntax: -

<@page isErrorPage="true/false">

The default value of isErrorPage is always false.

isELIgnored

This attribute can be used to enable or disable the usage of Expression Language tags. By default, the value is true.

<@page isELIgnored="true/false">

Thus, if there is no requirement of Expression Language tag then it can be disabled from JSP page.


Related Topics

JSP useBean, getProperty and setProperty tags

Java bean is a special type of Java class that contains private variables and public setter and getter methods. Java bean class implements Serializable interface and provides default constructor. JSP allows...

1 minute read.

JSTL Formatting Tags

In JSTL, the role of formatting tag is to specify the type of format that represents date and time. The following syntax represent the URL of formatting tag: - <%@ taglib...

1 minute read.

JSTL Function Tags

In JSTL, the purpose of function tags is similar to the various string methods in Java. Hence, these tag performs common string manipulation operations. Functional tag is represented by following URL:...

2 minutes read.

JSP session

In JSP, session object is used to establish a connection between a client and a server. It maintains the state between them so that server recognize the user easily. The session...

1 minute read.

JSP Implicit Objects

In JSP, implicit objects are pre-defined objects, created by the web container. These objects are created during the translation phase from JSP to Servlet. JSP allows you to call these...

1 minute read.

JSP Include Directive

As the name implies, include directive is used to include the content of other files such as HTML, JSP, text into the current JSP page. These files are included during...

1 minute read.

JSP Expression Language

JSP introduced the concept of expression language (EL) in JSP 2.0 version. The purpose of expression language is to access and manipulate data easily without using any type of scriptlet. Why...

1 minute read.

JSP Tutorial

Java Server Pages (JSP) is a server-side technology used to create static and dynamic web applications. The static content is expressed by text-based format files such as HTML, XML, SVG...

2 minutes read.

JSP out

In JSP, out is an implicit object that is associated with the response object. This object is used to write content to the output stream. Methods of JSP out Following are...

1 minute read.

JSTL XML Tags

In JSTL, XML tags are used for creating and manipulating xml documents. The following syntax represent the URL of XML tag: - <%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %> To utilize the functionality of...

1 minute read.

JSP Page Directive

JSP page directive provides various attributes with unique properties. These attributes can be applied to an entire JSP page. The syntax of Page directive is as follows: - <@page attribute="value"> Page directive...

3 minutes read.

JSP Expression Tag

JSP expression tag allows you to place the result of Java expression in a convenient way. It can be seen as an alternative of out.print() method. Thus, if we want to...

1 minute read.

Scripting in JSP

JSP scripting provides an easy and efficient way to insert Java programming language in JSP pages. Here, Java is a default language. JSP also allows you to use any other...

1 minute read.

JSTL - Java Standard Tag Library

Java Standard tag library (JSTL) is a collection of various type of JSP tags. Each tag control the behavior of JSP page and perform specific task such as database access,...

1 minute read.

JSP Scriptlet Tag

JSP scriptlet tag allows you to insert programming logic inside JSP page. Hence, you can put valid Java code within scriptlet tags. Each Java statement must be followed by a...

1 minute read.

JSP exception

Like Java, exceptions can also be occurred in JSP. To handle these exceptions, JSP exception object is used. Handling exceptions in JSP using exception object is much easier approach. This...

1 minute read.

JSP Directives

In JSP, the role of directive is to provide directions to the JSP container regarding the compilation of JSP page. Directives convey information from JSP page to container that give...

1 minute read.

JSP config

JSP config object is used to send the configuration information to JSP page. Here, config is an instance of servlet's ServletConfig interface. In this case, the information is send to...

1 minute read.

JSP application

JSP application object is an instance of servlet's ServletContext interface. It is used initialize parameter of one or more JSP pages in an application. Thus, the scope of application object...

1 minute read.

JSP Taglib Directive

Taglib directive is used to define tag libraries in JSP page. It enables user to use custom tags within JSP file. A JSP page can contains more than one taglib...

1 minute read.