• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
  • Skip to footer
  • Core Java
  • Design Patterns
  • JSP
  • Servlets
  • Building Tools
  • jQuery
  • Spring
  • Hibernate
  • Mongo DB
  • More
    • HTML
    • SCJP
    • AJAX
    • UML
    • Struts
    • J2EE
    • Testing
    • Angular JS

J2EE Reference

  • Home
  • About Us
    • Java Learning Centers
  • Contact Us

JSP Page Directives

April 24, 2011 By j2eereference

Almost all the JSP file contains the page directive which gives the information to the JSP engine about the entire source file.

Syntax for writing page directives

<% page

[language=” java “]

[extends = “package.class”]

[import={package.class  | package.*}]

[session=”true | false”]

[buffer=”none |8kb |sizekb”]

[autoflush=”true | false”]

[isThreadsafe=”true | false”]

[info=”text”]

[errorPage=”relative URL ”]

[contentType=”mimeType [;charset=characterset] “ | “text/html;charset=ISO-8859-1”]

[iserrorPage=”true | false”]

%>

Below are the attributes used in the page directives.

1.        language=”java”

This specifies the scripting language used in the scriptlets,declarations, expressions in the JSP file. Java is the only allowed value.

2.       extends=”package.class”

This will tell the JSP engine about the classes  which are to be extended in the particular JSP page.

3.       import=”package.class | package.*”

This attribute contains a list of java packages or classes that the JSP should import. More than one package can be imported by using comma separated list.

Below packages are implicitly imported in all the JSP page.

Java.lang.*

Javax.servlet.*

Javax.servlet.jsp.*

Javax.servlet.http.*

4.       session=”true | false”

This attribute specifies whether the client must join as Http session in order to use the JSP page. If the value is true , the session object refers to the current  or new session.  The default value is true.

5.       buffer=”none|8kb|sizekb”

This attribute specifies the buffer size in kilobytes used by the out object to handle output sent from the compiled JSP page to the client web browser. The default value is 8 kb . If you specify the buffer size,the output is buffered with the size specified .

6.       autoFlush=”true|false”

This attribute specifies whether the buffered output should be flushed automatically when the buffer is full. The default value is true. If it is set to true the buffer will be flushed otherwise , an exception will be raised when the buffer overflows.

7.       isThreadSafe=”true|false”

this attribute specifies whether the thread safety is implemented in the JSP file or  not. The default value is true.which means the JSP container can send multiple, concurrent client request to the JSP page.

8.       info=”text”

This specifies a text string that is incorporated into the compiled JSP page. This can be retrieved using the Servlet.getServletInfo() method.

9.       errorPage=”relativeURL”

This attribute specifies the pathname to a JSP file to where it has to send the exception.

10.   isErrorPage=”true|false”

this specifies the whether this JSP file display an error page. If set to true you can use the exception object in the JSP file . The default value is false.

11.   contentType=”mimeType [;charset=characterset] “ | “text/html;charset=ISO-8859-1”

The default mime type is text/html and the default character set is ISO-8859-1.

Filed Under: JSP

Reader Interactions

Comments

  1. Ashely Marr says

    May 29, 2011 at 10:27 pm

    Keep posting stuff like this i really like it

Primary Sidebar

FOLLOW US ONLINE

  • View J2eereference-166104970118637’s profile on Facebook
  • View j2eereference’s profile on Twitter
  • View j2eereference’s profile on LinkedIn

Subscribe by email

Recent posts

  • Java Buzzwords
  • Anonymous Inner Class in Java
  • Network Programming – java.net Package
  • Java Regular Expressions
  • Method Local Inner Class in Java
  • URL Processing in Java
  • Iterator Design Pattern Implementation using Java
  • Strategy Design Pattern Implementation using Java
  • Decorator Design Pattern
  • Adapter Design Pattern Implementation using Java
  • JSF Composite Components
  • JSF UI Components
  • What is JavaServer Faces (JSF)?
  • GOF Design Patterns
  • History and Need for Design Patterns

Footer

Core Java
Design Patterns
JSP
Servlets
HTML
Building Tools
AJAX
SCJP
jQuery
Testing
Spring
UML
Struts
Java Centers
Java Training
Home
About Us
Contact Us
Copyright © j2eereference.com. All right reserved.