JSP Directives

JSP Directives -

    JSP Directives is very powerful components in the Jsp. In this page you will learn about JSP Directives. JSP Directives are responsible for giving the special information about the jsp to the Jsp container.
Jsp Directives tag syntax is :
<%@ directive  attribute=”Value” %>
JSP has three type of jps Directives tag.
  1. page
  2. taglib
  3. include

page Directive :

page Directive is used for manipulating the behaviour of the jsp page. Jsp page can be import the java file through the import attribute. If isErrorPage attribute will be true then jsp will work as a error page.
There are list of attribute of page directive.
  1. autoFlush
  2. buffer    
  3. contentType
  4. errorPage
  5. extends
  6. import
  7. info
  8. isErrorPage
  9. isThreadSafe
  10. language
  11. pageEncoding
  12. session

autoFlush Attribute :-

autoFlush Attribute is used to flush the jsp page when buffer size is overflows. By-default the value of autoFlush attribute is true. If you will set value as false. It will throw exception in case buffer size will be increase.
Syntax of autoFlush Attribute is :
<%@ page     autoFlush="true" %>
buffer Attribute :-

buffer attribute is used to set the buffer size of your jsp page. By-default the value of buffer attribute is 8kb. If buffer size of jsp page will we 0kb then all output is immediately flushed.
Syntax of buffer attribute is :
<%@ page     buffer="8kb" %>
contentType Attribute:-

contentType Attribute is used for change the language accordingly. you can set the content type and charset through the contentType attribute.
Syntax of contentType attribute is :
<%@ page     contentType="text/html; charset=ISO-8859-1" %>
errorPage Attribute:-

errorPage Attribute is used for set the path of jsp error page. If any exception will occur in the jsp page, errorPage attribute forward the common jsp page.
Syntax of errorPage attribute is :
<%@ page     errorPage="path of error page" %>
extends Attribute:-

extends Attribute is used to define a super class of jsp page. Supper class can be a servlet.
Syntex of the extends attribute is :
<%@ page     extends="path of servlet" %>
import Attribute:-

import attribute is used to import one or more java class within the jsp.
Syntex of the import attribute is:
<%@ page     import="path of java class" %>
<%@ page     import="java.util.Date" %>
It means, in the compiled java class of jsp, you will file this line
import java.util.Date;
info Attribute:-

info attribute is used to write the documentation for the jsp. You can write like author name, version, copyright and date for the jsp.
Syntex of info attribute is:
<%@ page     info="some text" %>
<%@ page     info="@ Auther Name: Manoj Kumar Shakya
        @Date 30 Nov 2010" %>
isErrorPage Attribute:-

isErrorPage is used to define a jsp as a error page. By-default value of isErrorPage attribute is false. If you will set the value of isErrorPage as true it means this page will work for display the error.
Systex of isErrorPage is:
<%@ page     isErrorPage="false" %>
language Attribute:-

language Attribute is used to define the language which will be used as scriptlet language.
By-default value of language attribute is java.
Syntax of language atrribute is :
<%@ page     language="java" %>
session Attribute:-

session attribue is used to define that session object will be present at jsp page or not. By-default value of session attribute is true there you can use the session object within the jsp page. If you will set session is false. then session object will not be on that jsp page.
Syntax if session attribute is:
<%@ page     session="true | false" %>