Latest web development tutorials

JSP directives

JSP directive to set the entire JSP page related attributes, such as page coding and scripting languages.

Syntax is as follows:

<%@ directive attribute="value" %>

The instructions may have a number of properties, which in the form of key-value pairs, separated by commas.

The three kinds of instruction JSP tags:

instruction description
<% @ Page ...%> Custom page-dependent attributes, such as the scripting language, error pages, cache requirements, etc.
<% @ Include ...%> It contains additional files
<% @ Taglib ...%> The introduction of custom tag library

Page directive

Page command provides the current instructions for use page container. A JSP page can contain multiple page instructions.

Page command syntax:

<%@ page attribute="value" %>

Equivalent XML format:

<jsp:directive.page attribute="value" />

Attributes

The following table lists the attributes associated with the Page directive:

Attributes description
buffer Specifies the size of the buffer objects out
autoFlush Out control object cache
contentType Specify the current MIME type and character encoding JSP page
errorPage Specifies an exception occurs when the JSP pages need to turn to error-handling page
isErrorPage Specifies whether the current page can be handled as an error page to another JSP page
extends Specifies where a servlet class inheritance
import Import Java class to use
info Defined description of the JSP page
isThreadSafe Access to specify whether the JSP page thread safe
language Scripting language used to define JSP page, the default is Java
session Specifies whether JSP pages use session
isELIgnored Specifies whether EL expressions
isScriptingEnabled It can be used to determine the script element

Include instructions

JSP can contain other files include directives. Included files can be JSP files, HTML files or text files. File contains is like part of the JSP file will be compiled simultaneously executed.

Include command syntax is as follows:

<%@ include file="文件相对 url 地址" %>

include instruction in the filename is actually a relative URL address.

If you do not have to associate a file path, JSP compiler defaults to find in the current path.

Equivalent XML syntax:

<jsp:directive.include file="文件相对 url 地址" />

Taglib instruction

JSP API allows users to customize the label, a custom tag library is a collection of custom labels.

Taglib directive introduces a custom-defined set of tags, including the library path, custom labels.

Taglib command syntax:

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

uri attribute determines the location of the tag library, prefix attribute specifies the tag library prefix.

Equivalent XML syntax:

<jsp:directive.taglib uri="uri" prefix="prefixOfTag" />