JSP compilation command-PGE

Source: Internet
Author: User

Defines the global attributes in the JSP file.
JSP syntax
<% @ Page
[Language = "Java"]
[Extends = "package. Class"]
[Import = "{package. Class | package. *},..."]
[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"]
%>

Language: Declares the type of script language used for the current JSP page. Because the page is a JSP page, the value of this attribute is generally Java.
Extends: determines the Java class generated during JSP program compilation, the parent class to be inherited, or the fully qualified class name of the interface to be implemented.
Import: used to import packages. The following packages are automatically imported by default and do not need to be explicitly imported. The default imported packages include: Java. Lang. *; javax. servlet. *; javax. servlet. jsp. *; javax. servlet. http .*
Session: sets whether htip session is required for this JSP page.
Buffer: specify the size of the output buffer. The internal JSP object of the output buffer: Out is used to cache the output of the JSP page to the client browser. The default value is 8 KB. It can be set to none or another value, in KB.
Autoflush: whether to force the output buffer content when the output buffer is about to overflow. If it is set to true, the output is normal. If it is set to false, an exception occurs during Buffer Overflow.
Info: Set the information of the JSP program, which can also be seen as its description. You can obtain the value through servlet. getservletinfo. If you are on a JSP page, you can directly call the getservletinfo () method to obtain the value, because the JSP page is essentially a servlet.
Errorpage: Specifies the error handling page. If an exception or error occurs in this program and the JSP page does not have the corresponding processing code, the JSP page specified by this instruction is automatically called. When Using JSP pages, you can ignore exceptions, even if they are checked exceptions.
Iserroepage: sets whether the JSP page is an error handler. If the page itself is an error handling page, you do not need to use the errorpage attribute.
Contenttype: used to set the file format and encoding method of the generated web page, that is, the MIME type and the page Yu character set type, the default MIME type is textlhtml; the default character set is the ISO-8859-1.
Example
<% @ Page import = "Java. util. *, java. Lang. *" %>
<% @ Page buffer = "5kb" autoflush = "false" %>
<% @ Page errorpage = "error. jsp" %>
Description
<% @ Page %> the command acts on the entire JSP page, and also includes static inclusion files. However, the <% @ Page %> command cannot act on dynamic include files, such as <JSP: Include>

 

You can use multiple <% @ Page %> commands on a page, but the attributes can only be used once. However, there is an exception, that is, the import attribute. Because the import attribute is similar to the Import Statement in Java (refer to Java language), you can use this attribute several times.

 

No matter where you place the <% @ Page %> command in the JSP file, it applies to the entire JSP page. However, for the sake of readability and good programming habits of the JSP program, it is best to put it on the top of the JSP file.

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.