JSP Simple Practice-JSP Instructions

Source: Internet
Author: User

One, page directive:

When you define a global property value for a JSP page, you can use the page directive, which is typically placed in the header of the pages.

<%@ page contenttype= "text/html; charset=gb2312 "%>
Note: The ContentType property in the page directive cannot be assigned a value two times in the same page.

The properties of the page directive are much more, and the attributes enclosed in square brackets "[]" represent optional properties.

1, Language:

Language defines the scripting language used by the page, which by default is Java, so this property does not have to be set when writing a JSP program.

2. Import:

The Import property is common. It is used to import a package or class to be used in a program, and this property can have multiple values. This class can be used in a JSP program, whether it is a class that comes with a Java core package or a class that is written by the user itself, and is referenced in import.

3, ContentType:

The ContentType property sets the MIME (multipurpose Internet Mail extention) type of the JSP page. The format of the setting type is "MIME" or "Mimi type; charset= encoding". The character encoding that is set by default in the JSP page is iso-8859-1, which is type= "text/html;charset=iso-8859-1".

4. Session:

The session property sets whether the session object needs to be used in the JSP page. If False, the session object and Scope=session's JavaBean or EJB cannot be used in the JSP program. The default value for this property is true.

5. Buffer:

The value of buffer can have none, 8kb, or a given KB value, none means no cache, direct output to the client's browser, this property is used to set the size of the buffer processed by the Out object cache.

6, Autoflash:

The Autoflash property sets whether the buffer is automatically refreshed when the buffer is full. If the value is False, an exception occurs when the buffer overflows, and the value of this property cannot be set to False when the value of buffer is set to none. The default value for this property is true.

7, IsThreadSafe:

The IsThreadSafe property sets whether the JSP page can be accessed multithreaded. If the value is true, this JSP page can respond to requests from multiple customers at the same time, and if False, only one customer's request can be processed at a time. The default value for this property is 0.

8. Info:

The Info property sets the information string for the JSP page, which can be a descriptive text for this JSP page, using the Getservletinfo () method to get the string. Why would it be getservletinfo ()? Because the JSP engine actually translates the JSP into a servlet and then responds to the client's request.

9, ErrorPage:

The ErrorPage property sets the URL to the page when an exception occurs.

10, Iserrorpage:

Iserrorpage whether the property is set to an error page. If true, you can use the exception object, or False if it is not. The default is false, so be aware that the value of setting this property in the page directive is true in a JSP page that needs to use the exception object.

Ii. include directives:

The include directive is used to statically insert a file at that instruction, similar to # include in C, which simply combines the file code with this file to form a large program file. The syntax format for the include directive invocation is as follows:

<%@ include file= "file path"%>
File paths typically use relative paths, so that if the program code files are migrated, they will not be affected. If the path begins with "/", the path of the root directory relative to the JSP server application is used, if the file name or folder name + file name is the relative path of the current directory relative to the JSP file. Be sure to include the same syntax as the containing file when you include it, and use the include directive in the appropriate location.



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.