Home Tutorial Jsp JSPs : Directives

 
 

Share on Google+Share on Google+
JSPs : Directives
Posted on: November 22, 2012 at 12:00 AM
Advertisement
This section contains the description of Directives which is one of JSPs components.

JSPs : Directives

This section contains the description of Directives which is one of JSPs components.

Directives :

A directives tag always appears at the top of your JSP file. It is global definition sent to the JSP engine. Directives contain special processing instructions for the web container. You can import packages, define error handling pages or the session information of the JSP page. Directives are defined by using <%@ and %> tags.

Syntax -

<%@ directive attribute="value" %>

Types of Directives :

There are three kinds of directives we use -

  • page directive
  • include directive
  • taglib directive

page Directives :

Functionality of page directive is to define the page dependent attributes to the JSP container. For example scripting language, error page, and buffering requirements. In general we write page directives at the top of the JSP page. page is used to provide the information about it.

Syntax -

<%@ page attributes="value" %>

attributes associated with page directive:
buffer, autoFlush, contentType, errorPage, isErrorPage, extends, import, info, isThreadSafe, language, session, isELIgnored, isScriptingEnabled

Example:  <%@page language="java" %>

include Directives :

Functionality of include directives is to include a file at the time of page translation. The web container merges the content of included files with your JSP pages at translation time.

Syntax -

<%@ include file="url of file" >

url of file is the actual location of the file you are including. If you just specify a filename with no associated path, the JSP compiler assumes that the file is in the same directory as your JSP.

Example: <%@ include file="/test.jsp" %>

taglib Directive :

For user-defined tags we use taglib directives. JSPs permits you to define your own JSP tags which looks like HTML or XML.

Syntax-

<%@ taglib uri="uri" prefix="prefixOfTag" >

Example : <%@ taglib uri="tlds/taglib.tld" prefix="mytag" %>

Advertisement

Related Tags for JSPs : Directives :


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 22, 2012

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com