Jsp Directive

Jsp Directives:

Jsp Directives gives instruction to web container for how to translate the Jsp to servlet.

Types:

-> page Directive

-> include Directive

-> taglib Directive

Page Directive:

Syntax:

  <%@ page attribute="value" %>

Attributes:

buffer: It specifies a buffer for the output stream.

e.g

  <%@ page buffer="100kb" %>

autoFlush:

contentType:

e.g

  <%@ page contentType="application/msword" %> 

errorPage: It specify the another jsp page url for catching run time exception or displaying customized message in case of any exception.

e.g

  <%@ page errorPage="error.jsp" %> 

isErrorPage: JSP page is a URL specified by another JSP page's errorPage attribute.

e.g

  <%@ page isErrorPage="true" %>  

extends: Extend a superclass that the generated servlet must extend.

import: Here we specify the list of packages or classes for use in the JSP as the Java import statement does for Java classes.

e.g

  <%@ page import="java.util.*" %> 

info: It sets the information of the JSP page which can be retrieved using getServletInfo()

isThreadSafe: Jsp is multithreaded. Default value is true if we set this as false then it will work as single threaded modle.

language: It specify the scripting language. Default value is java.

session:

isELIgnored: Specifies whether or not EL expression within the JSP page will be ignored.

isScriptingEnabled: Determines if scripting elements are allowed for use.

include Directive:

It is used to include the file at the translation time.

Syntax:

  <%@ include attribute="value" %>

Attribute:

file: Here we specify the file name generally html or jsp page.

e.g:

  <%@ include file="header.html" %>

It is used for code reusability.

Taglib Directive:

It specify the tag library which is having many tags. It is used for specifying both custom and existing tags.

Syntax:

  <%@ taglib attribute="value" %>

Attributes:

uri: In this we specify the uri of tag library.

prefix: It specify the prefix of tags specified in the tag library.

e.g

  <%@ taglib uri="http://abc.com/tags" prefix="a"%>

Then tag will be like:

  <a:user>