JSP Basics Summary SCRIPT element

Source: Internet
Author: User

JSP scripting elements

1. JSP declaration statement

The JSP declaration statement begins with <%! and ends with%> in the syntax format: <%! Statement Statement%>

Variables that use declaration statements are global variables, that is, when more than one user executes the JSP page, the variable is shared.

2. JSP Scriptlets

JSP scriptlets begins with <% and ends with the%>, which contains Java code that effectively conforms to the Java syntax rules, in the syntax format: <% java code%>. In JSP scriptlets, you can include multiple statements, such as methods, variables, expressions, and so on.

3. JSP expression

The JSP expression begins with <%= and ends in%> with the syntax format: <%= java code%>. The code in the JSP expression is executed first, then converted to a string and displayed on the Web page.

4. Comments

The comments of the JSP are divided into two categories, one for annotations that can be displayed on the client, that is, an HTML comment, and a comment that cannot be displayed on the client, that is, a JSP comment.

HTML annotations start with <!--, and end with the code in the middle that is the comment section.

JSP annotations start with <%--, end with--%>, and the code in the middle contains the comments section.

It is also possible to use Java annotations in JSP scripting elements, and/or, not to be displayed in HTML source code.

JSP directive element

1. Page directive

The page directive is used primarily to set the global properties of a JSP page, which will act on the entire JSP page, even including statically contained files. Its syntax is formatted as follows.

<%@ Page Property 1 = "Property value 1" Property 2 = "Property value 2"%>

The page directive consists of 13 attributes:

1) The language attribute, which is used primarily to declare the type of scripting language used. It can only be Java for the time being.

<%@ page language= "java"%>

2) The Extends property, which specifies which parent class the servlet generated by the JSP page inherits from, must specify the full name of the class when set, that is, the package name plus the class name, which is rarely used.

<%@ page extends= "Inherited parent class"%>

3) Import property to specify the imported Java package.

4) Session property to specify whether the session object can be used in the JSP page.

<%@ page session= "true"%>

5) The Buffer property, which specifies whether the output stream has a buffer and sets the buffer size. If set to none, the output stream does not have buffering capabilities, such as setting specific data, such as "40KB", to indicate that the buffer size is set to 40KB.

6) The AutoFlush property, which specifies whether the buffer automatically forces the output. If set to True, the output is normal when the buffer is full, and if set to False, an exception is generated when the buffer is full, and if the property of buffer is set to none, the AutoFlush property cannot be set to false.

7) The IsThreadSafe property, which specifies whether the JSP file supports multithreaded use.

8) Info property, which is used to set information about the JSP file, can be any information string

9) The ErrorPage property, which is used to set the Web page to jump back to the JSP file that can handle the exception when an exception occurs in the current JSP file.

The Iserrorpage property is used to specify whether the JSP file is a JSP file capable of handling exceptions.

One) the ContentType property, which specifies the MIME format of the JSP file, as well as the Web page encoding format.

<%@ page contenttype= "text/html;charset=iso-8859-1"%> gb2312 can display Chinese

Pageencoding property to specify the encoding format of the Web page

<%@ page pageencoding= "Iso-8859-1"%>

The Iselignored property is used to specify whether the JSP file supports an El expression.

2. include directive

Used to insert a file that contains text or code in a JSP file. The JSP file will resume execution only if the contained file has been executed.

<%@ include file= "included file Address"%>

The include directive has only file one property value

3. taglib directive

Used to declare that this JSP file uses a custom label, referencing the specified tag library and setting the tag library prefix.

<%@ taglib uri= "uritotaglibrary" prefix= "TagPrefix"%>

JSP Basics Summary SCRIPT element

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.