Javaserver Pages





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
JSP Tutorial
Introduction Introduction
Installing JDK-Windows Installing JDK-Windows
Installing JDK-Linux Installing JDK-Linux
Installing Tomcat Installing Tomcat
Simple Program in JSP Simple Program in JSP
Pre-defined Variables Pre-defined Variables
Syntax of Tags Syntax of Tags
JSP Expression Language JSP Expression Language
JSP EL Operators JSP EL Operators
EL Implicit Variables EL Implicit Variables
Scopes Scopes
Using Arrays Using Arrays
Methods Methods
JSP Elements JSP Elements
Including Beans Including Beans
JSTL Tags JSTL Tags
Custom Tags Custom Tags
Session Session in JSP
Handling Cookies Handling Cookies
JSP Application Structure JSP Application Structure
Configuring web.xml Configuring web.xml
Tomcat Configuration Tomcat Configuration
JSP Examples JSP Examples
Forums Ask Your Doubts
Feedback Feedback
 




Include Directive in JSP


Tutorials Jsp

Topic

How is Page Directive used in JSP?



Explanation

Usually a page directive tag specifies the attributes that are common to the whole JSP page.

Syntax:
    <%@ page [language="" ] [ extends="" ] [ import="" ] 
    [ session="t|f" ] [ buffer="" ] [ autoFlush=" " ]
    [ isThreadSafe=" " ][ info=" " ] [ errorPage=" " ] 
    [ contentType=" " ] [ isErrorPage=" " ] %>

Following table lists the atrributes of Page Directive.

Attributes Description
language Specifies the language used in the page,for JSP it can be only "java".
extends Specifies whether the page uses an extended class
import Specifies the classes to be imported
session It is used to make a session value available to a jsp page, this attribute has a "boolean" value and its "true" by default.
autoflush This is used to flush the buffer if it is set to "true" else it will not.
buffer Specifies the pages buffer size
isThreadSafe Specifies multi threading if it is set to "true", if set to "false" only one request is sent.
errorPage Specifies the error page location for unhandled exceptions.
contentType Specifies the content and mime type.
isErrorPage Specifies whether to use the exception object,it is set to "true" to use the exception object, else it can be set to "false".

Example:
   <%@page contentType="text/html" import="java.util.Date" %>
   <p>Current Date is ::</p>
   <%= new java.util.Date() %>
Result:
    Current Date is ::
    Thu Dec 10 11:22:56 IST 2009 

In the above example we have used the page directive attribute "import" to import the java class "java.util.Date", using this class the current date is displayed using the new instance of the class.






A Note
JSP(Java Server Pages) is one of the most used Server Side Programming Language in the world. Simple introduction, basic program codes with examples. Begin coding your own JSP scripts with this online tutorial. Hope you enjoy this tutorial. Do send your feedback or suggestions on this JavaServer Pages tutorial. This is a copyright content.


Other Links

web hosting