Common instruction learning and JSP development instruction in jsp development

Source: Internet
Author: User

Common instruction learning and JSP development instruction in jsp development

(1) JSP commands

JSP Commands include page commands, include commands, and taglib commands.

(2) role of the page command

Syntax:

<% @ Page property name 1 = "property value 1"... property name n = "property value n" %>

1. import: import a Java class or package on the specified JSP page.

2. session: Restrict whether the session is available. The default value true indicates that the session is available, and fasle is unavailable.

3. isErrorPage: Specifies whether the JSP page is used to handle abnormal error pages. If it is set to true, exception is available. The default value is false.

4. errorPage = "URL": when a page exception occurs, it is the jump path.

5. contentType = "text/html; charset = UTF-8": the browser determines the document type based on the appearance.

6. pageEncoding: Specify the page encoding format.

7. autoFlush = "true | false": indicates whether the buffer is automatically cleared. The default value is true.

8. info = "text": describes information about the JSP page.

9. isThreadSafe = "false | true": whether to allow multithreading to use this page. The default value is true.

10. buffer = "8 KB": indicates whether the output stream has a cache. The default value is 8 KB.

11. Extends = "class": Specifies the parent class inherited by the Servlet generated on the JSP page.

(3) include commands to introduce files

<% @ Include file = "file path (either absolute or relative)" %>

Instance demo

<% @ Page import = "java. util. date "%> <% @ page language =" java "contentType =" text/html; charset = UTF-8 "pageEncoding =" UTF-8 "%> <! -- Embed HTML in JSP --> <! DOCTYPE html PUBLIC "-// W3C // dtd html 4.01 Transitional // EN" "https://www.w3.org/TR/html4/loose.dtd"> 

Output:

(3) taglib commands related to tags

Import package: jstl-1.2.jar, jstl-standard.jar

<% Taglib uri = "tagliburi" prefix = "tagPre" %> uri: indicates the location where the custom tag library is stored. prefix: distinguishes the tag names of different tag libraries.

Example:

<% @ Page language = "java" contentType = "text/html; charset = UTF-8 "pageEncoding =" UTF-8 "%> <% @ taglib uri =" https://java.sun.com/jstl/core_rt "prefix =" c "%> <! DOCTYPE html PUBLIC "-// W3C // dtd html 4.01 Transitional // EN" "https://www.w3.org/TR/html4/loose.dtd"> 

In the browser address bar, output: https: // localhost/Project/index. jsp? Username = "Kaina ":

Output:

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.