JSP tutorial (II)

Source: Internet
Author: User

JSP directive mso-hansi-font-family: ""> affects the overall structure of the servlet class. It is commonly used in the following forms:

<% @ Directive attribute = "value" %>

In addition, you can write multiple attributes in one statement:

<% @ Directive attribute1 = "value1"
Attribute2 = "value2"
AttributeN = "valueN" %>

There are two main types of VE ve:

Page, allows you to do something similar to import classes, define the servlet Superclass ),
Mso-hansi-font-family: ""> and so on;

Include, which allows you to insert files into the servlet class (when the JSP file is translated as servlet ).

I. JSP page Directive

<% @ Page
[Language = "java"]
[Extends = "package. class"]
[Import = "{package. class |. *},..."]
[Session = "true | false"]
[Buffer = "none | 8kb | sizekb"]
[AutoFlush = "true | false"]
[IsThreadSafe = "true | false"]
[Info = "text"]
[ErrorPage = "relativeURL"]
[ContentType = "mimeType [; charset = characterSet]" |
"Text/html; charset = ISO-8859-1"]
[IsErrorPage = "true | false"]


Page directive mso-hansi-font-family: ""> allows you to define case-sensitive attributes:

(1) import = "package. class" or import = "package. class1,..., package. classN ".
Mso-hansi-font-family: "">
You can specify the packages you want to import. For example:

<% @ Page import = "java. util. *" %>

The import attribute is the only one of these attributes that can appear multiple times in a JSP.

(2) contenType = "MIME = Type" or contentType = "MIME-Type; charset = Character-Set"
Mso-hansi-font-family: "">
It specifies the MIME type of the output. The default value is "text/html ". For example:
<% @ Page contentType = "text/plain" %>"

Medium price in scriptlet:

<% Response. setContentType ("text/plain"); %>

(3) isThreadSafe = "true | false ". if the value is "true" (default), it means that a common servlet will be processed, and multiple requests will be processed in parallel by one servlet instance. In this case, programmers synchronously Access Multiple instance variables. When the value is "false", the servlet will implement the SingleThreadModel. no matter whether the request is submitted sequentially or concurrently, different isolated servlet instances will be provided.

(4) session = "true | false ". If the value is "true" (default), it indicates that the predefined variable session (inheriting HttpSession) should be bound to an existing session; otherwise, it should be created and bound. If the value is "false", the session variable will not be used. If you try to use it, an error will occur when JSP is converted to servlet.

(5) buffer = "sizekb | none ". Determine the buffer size for the JspWriter output. The default value is determined by the server, but at least 8 KB is required.

(6) autoflush = "true | false ". If the value is "true mso-hansi-font-family:" ">" (default), the system automatically clears the buffer when it is full, if the value is "false mso-hansi-font-family:" ">", an exception is thrown when the buffer is full, which is rarely used. When buffer = "none" is false, the mso-hansi-font-family: ""> value is invalid.

(7) extends = "package. class ". This will generate a superclass for the servlet. Please use this feature with caution, because the server may have defined one.

(8) info = "message ". Defines a string that can be obtained by calling the getServletInfo method.

(9) errorPage = "URL ". Specify a JSP mso-hansi-font-family: ""> page to handle any unexpected error that can be thrown but not processed on the current page.

(10) isErrorPage = "true | false ". Specifies whether the current page can handle errors from another page. The default value is "false ".

(11) language = "java" mso-hansi-font-family: "">. Specify the following language. However, you don't have to worry about this property because "java mso-hansi-font-family:" ">" is both a default and a legal choice.

Two JSP include Directive direve ve allows you to include a file when JSP is converted to servlet. Syntax:
<Jsp: include page = "{relativeURL | <% = expression % >}" flush =" true "/> mso-hansi-font-family :"; mso-font-kerning: 0pt "> or
<Jsp: include page = "{relativeURL | <% = expression %>}" flush = "true">
<Jsp: param name = "parameterName"
Value = "{parameterValue | <% = expression % >}"/> +
</Jsp: include>

URL mso-hansi-font-family: ""> generally, relative to the JSP page pointing to it ", you can use the slash "/" as the starting URL to inform the system of the main path of the relative Web server URL mso-hansi-font-family: "">. The contained files are parsed in the form of JSP rules. Therefore, you can use static HTML, scripting elements, directives, and actions.

Let's look at an example. Many sites contain a small navigation bar on each page. It usually appears at the top or right of the page and is contained in every page. It is natural to use include directive to implement it. It is a nightmare to copy these statements to every page using the HTML mso-hansi-font-family: ""> rule. See the following code:
<TITLE> JSP tutorial </TITLE>
<% @ Include file = "/navbar.html" %>
<! -Other parts of this page... -->
Because the file is inserted when the page is converted, if the navigation bar changes, you need to put all JSP mso-hansi-font-family pointing to it: ""> the page is all re-compiled once. If your navigation bar is not changed frequently, it is undoubtedly efficient. However, if your included files are frequently changed, we recommend that you use jsp: include action (which will be discussed later) it only contains files when the page is requested.

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.