Java Record-jsp Instructions

Source: Internet
Author: User
Tags tag name

There are three types of directive tags in the JSP-

Serial Number instruction Description
1 <%@ page ... %> Defines page-related properties, such as scripting language, error pages, and buffering requirements.
2 <%@ include ... %> Include files in the compile phase.
3 <%@ taglib ... %> A tag library that contains custom actions used in the claims page

The directives in the JSP are page used to provide the container with instructions related to the current JSP page. You can use directives to encode anywhere in a JSP page page . By convention, page directives are encoded at the top of the JSP page.

The following is page the basic syntax of the instruction-

<%@ page attribute = "value" %>
Html

You can write the above syntax using XML, as follows:

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

Property

The following table lists the page properties associated with the directive-

Serial Number Properties Description
1 buffer Specifies the buffer model for the output stream.
2 autoFlush Controls the behavior of the servlet output buffers.
3 contentType Defines the character encoding scheme.
4 errorPage Defines another URL that reports the JSP that Java does not check for runtime exceptions.
5 isErrorPage Indicates whether this JSP page is a URL specified by the properties of another JSP page errorPage .
6 extends Specifies the superclass that the generated servlet must extend.
7 import Specifies a list of packages or classes used in the JSP, just like a Java import statement.
8 info Defines a string that can be accessed using the method of the servlet getServletInfo() .
9 isThreadSafe Defines the threading model of the generated servlet.
10 language Defines the programming language used in JSP pages.
11 session Specifies whether the JSP page participates in an HTTP session
12 isELIgnored Specifies whether an El expression in a JSP page is ignored.
13 isScriptingEnabled Determines whether the script element is allowed to be used.
1. Buffer Property

bufferproperty specifies the buffering characteristics of the server output response object.

You can write a none value that specifies not to use buffering so that the servlet output is immediately directed to the response object, or you can write a KB maximum buffer size in units, which instructs the servlet to write to the buffer before writing the response.

To instruct the servlet to write output directly to the response output object, use the following command-

<%@ page buffer = "none" %>
Html

Use the following command to instruct the servlet to write output to buffers that are not less than 64KB bytes in size-

<%@ page buffer = "64kb" %>
Html2. AutoFlush Properties

autoFlushproperty specifies whether the buffer output is automatically refreshed when the buffer is populated, or whether an exception is thrown to indicate a buffer overflow.

trueThe (default) value indicates an automatic buffer flush, and the false value indicates an exception was thrown.

When the output buffer of the servlet is full, the following instruction causes the servlet to throw an exception, using the following statement-

<%@ page autoFlush = "false" %>
Html

This directive causes the servlet to flush the output buffer when full output is

<%@ page autoFlush = "true" %>
Html

Typically, buffer and autoFlush attributes are page encoded in directives, as follows:

<%@ page buffer = "16kb" autoflush = "true" %>
Html3. ContentType Properties

contentTypeproperty to set the character encoding of the JSP page and the generated response page. The default content type text/html is:, which is the standard content type for an HTML page.

If you want to output from a JSP as XML, use the following page directives-

<%@ page contentType = "text/xml" %>
Html

The following statement indicates that the page generated by the browser is rendered as HTML-

<%@ page contentType = "text/html" %>
Html

The following instruction sets the content type to: Microsoft Word document-

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

You can also specify the character encoding of the response. For example, if you want to specify a result page that returns a browser using:UTF-8, you can use the following page Directive-

<%@ page contentType = "text/html:charset=UTF-8" %>
Html4. ErrorPage Properties

If you want to specify an error page when an error occurs while the current page is running, the errorPage property tells the JSP engine which page to display. errorPagethe value of the property is a relative URL.

When all uncaught exceptions are thrown, the following instruction is used to specify what is displayed when the page is faulted MyErrorPage.jsp -

<%@ page errorPage = "MyErrorPage.jsp" %>
Html5. Iserrorpage Properties

isErrorPageproperty indicates that the current JSP page can be used as an error page for another JSP.

isErrorPageThe value can be true either or false . isErrorPagethe default value for the property is false .

For example handleError.jsp , isErrorPage set the option to true , because it should handle the error-

<%@ page isErrorPage = "true" %>
Html6. Extends Properties

extendsproperty specifies the superclass that the generated servlet must extend.

For example, the following directive instructs the JSP converter to generate a servlet so that the servlet extends somePackage.SomeClass -

<%@ page extends = "somePackage.SomeClass" %>
Html7. Import Properties

importThe property is functionally identical to the Java import statement and is similar to the Java import statement. The import value of the option is the name of the package to be imported.

For example, to import java.sql.* , use the following page directives-

<%@ page import = "java.sql.*" %>
Html

To import multiple packages, you can use commas to separate them, as follows:

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

By default, containers are automatically imported java.lang.* , javax.servlet.* javax.servlet.jsp.* and javax.servlet.http.* .

8. Info Property

infoproperty allows you to provide a description of the JSP. The following is a code example-

<%@ page info = "This JSP Page Written By Maxsu"  %>
Html9. IsThreadSafe Properties

isThreadSafeOption to mark the page as thread safe. By default, all JSPs are considered thread-safe. If you isThreadSafe set the option to false , the JSP engine ensures that only one thread is executing the JSP at a time.

The following page instruction isThreadSafe sets the value of the option to false -

<%@ page isThreadSafe = "false"  %>
HtmlLanguage Properties

languageproperty indicates the programming language used in JSP page scripting.

For example, since we usually use Java as the scripting language, the language options can be set as follows:

<%@ page language = "java" %>
HtmlOne . Session Properties

sessionproperty indicates whether the JSP page uses an HTTP session. If the setting value is true , the JSP page can access the built-in session object, setting the value to false indicate that the JSP page cannot access the built-in session object.

The following directives allow JSP pages to use any built-in session object methods, such as: session.getCreationTime() or session.getLastAccessTime() -

<%@ page session = "true" %>
Htmliselignored Properties

isELIgnoredproperty to disable evaluation of expression language (EL) expressions introduced in JSP 2.0.

isELIgnoredThe default value of the property is true, which means that the expression ${...} is evaluated by the JSP specification. If the property is set to, the expression is evaluated for evaluation and is false treated as static text content.

The following instruction set expression is not evaluated-

<%@ page isELIgnored = "false" %>
Htmlisscriptingenabled Properties

isScriptingEnabledproperty determines whether the script element is allowed to be used.

isScriptingEnabledThe default value for true the property is, which represents the enable script, expression, and declaration. If the value of the property is set to false , then a conversion error is thrown if the JSP uses any script, either an expression (non-EL) or a declaration.

If you want to restrict the use of scripts, expressions (not el) or declarations, you isScriptingEnabled can set the value of the property to false -

<%@ page isScriptingEnabled = "false" %>

include directive is used to include a file during the compilation phase. This instruction tells the container to merge the contents of other external files into the current JSP file during the compilation phase. You can use directives to encode anywhere in the JSP page include .

The general form of use of this directive is as follows:

<%@ include file = "relative url" >

includeThe file name in the directive is actually a relative URL. If you specify only a file name that does not have an associated path, the JSP compiler assumes that the file is in the same directory as the JSP.
You can write the preceding code in XML with the same effect as follows:

<jsp:directive.include file = "relative url" />

The JSP API allows you to customize JSP tags, such as HTML or XML tags, which are a set of user-defined tags that implement custom behavior.

taglibThe directive declaration JSP page uses a set of custom labels, identifies the location of the library, and provides a way to identify the custom label in the JSP page.

taglibThe instruction follows the syntax given below-

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

Here, the uri property value resolves to the location that the container understands, and the prefix attribute notifies the container where the tag is a custom action.
You can write the above syntax using XML, as follows:

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

When you use a custom label, it is usually <prefix:tagname> the form. The prefix is the same as the taglib prefix specified in the directive, and the tag name is the name of the tag implemented in the tag library.

 

Java Record-jsp Instructions

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.