This section contains the description of Directives which is one of JSPs components.
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.
<%@ directive attribute="value" %>
Types of Directives :
There are three kinds of directives we use -
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.
<%@ page attributes="value" %>
attributes associated with page directive:
buffer, autoFlush, contentType, errorPage, isErrorPage, extends, import, info, isThreadSafe, language, session, isELIgnored, isScriptingEnabled
Example: <[email protected] 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.
<%@ 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.
<%@ taglib uri="uri" prefix="prefixOfTag" >
Example : <%@ taglib uri="tlds/taglib.tld" prefix="mytag" %>
Posted on: November 22, 2012 If you enjoyed this post then why not add us on Google+? Add us to your Circles