In this section, you will study about the Directive tag. It allows the JSP engine to processes the page. By using the directive tag, user can import different packages, handles the errors, or session information of JSP page. These are classified in three categories:
- Page
- Include
- Tag Lib
Syntax and usage of directive tag :
1. Page Directives: There are the many attributes are available for page directives which is used to give the special processing information to the JSP Engine that are:
- language
- extends
- import
- session
- buffer
- autoFlush
- isThreadSafe
- info
- errorPage
- IsErrorPage
- contentType
language:- This attribute is used to denote the language used by a file. Language denotes the scripting language used in script lets, declarations, and expressions in the JSP page and any included files.
Syntax of language attribute is: <%@ page language = "java" %>
extends:- This is used to signify the Super class of the Java class used by the JSP engine for the translated Servlet.
Syntax of extends attribute is: <%@ page extends = "package.class"%>
import:- The import attribute is used to import all the classes in a java package into the current JSP page. With this facility, the JSP page can use other
Syntax of import attribute is: <%@ page import = "java.util.*" %>
session:-
buffer:- It controls the use of buffered output for a JSP page then the buffer attribute can be made use of for achieving this.
Syntax of buffer attribute is: <%@ page buffer = "none|8kb|sizekb" %>
autoFlush:- This attribute is used to specify whether automatically flush out the output buffer when it is full or not.
Syntax of autoFlush attribute is: <%@ page autoFlush = "true|false" %>
isThreadSafe:- This attribute is used to set whether the generated Servlet handles multiple requests or single requests, depending on the set value of true or false. isThreadSafe attribute is used to set and ensure whether thread safety is implemented in the JSP page.
Syntax of isThreadSafe attribute is: <%@ page isThreadSafe="true|false" %>
info:- Programmers make use of info attribute to place the information or documentation for a page. Details such as: author, version, copyright and date are placed in this attribute. This is actually text string that is written as input text in the compiled JSP page.
Syntax of info attribute is: <%@ page info = "text" %>
errorPage:- If the programmer wants to place errors in a different page then the URL to the error page can be mentioned in this attribute as errorPage.
Syntax of errorPage attribute is: <%@ page errorPage = "relativeURL" %>
isErrorPage:- This attribute is used to specify whether or not a JSP page displays an error page by setting the value as true or false. By default, the value is set to false, meaning that the user cannot make use of the exception object in the JSP page. If the value is set to true, then it means that the user can make use of the exception object in the JSP page.
Syntax of isErrorPage attribute is: <%@ page isErrorPage="true|false" %>
contentType:- This attribute is used to set the mime type and character set of the JSP. The user can make use of any MIME type or character set valid for the JSP container.
Syntax of contentType attribute is: <%@ page contentType="mimeType [; charset=characterSet]" %>
2. Include Directives:- This is a type of directive tag. If a programmer wants to include contents of a file inside another, then the Include directive is used. The file included can be either static ( HTML file) or dynamic (i.e., another tag file). The Include directive is used to include the contents of other file in the current tag file.
Syntax of Include directive is: <%@ include file = "xxx.html/xx.tagf"%>
For example: The user includes a dynamic file in the include directive: <%@ include file="javasks.tagf" %>.
3. Tag Lib Directives:- A user can customize actions from their tag file using the Tag Lib directive. The Tag Lib directive is a collection of custom tags.
The syntax of Tag Lib directive is: <%@ taglib uri = "tag library URI" prefix = "tag Prefix" %>
scriptlet tag:- This tag is a type tag used for inserting
Reference Sit:- http://www.exforsys.com/tutorials/jsp/jsp-directive-tag.html.
No comments:
Post a Comment