JSP tags and four domain objects for web Development

Source: Internet
Author: User

 

JSP tag

JSP tags are also called Jsp Action elements. They are used to provide business logic functions on JSP pages, avoiding the difficulty of maintaining Jsp pages by writing java code directly on JSP pages.

Common JSP labels

<Jsp: include> tag

<Jsp: include> the tag is used to insert the output content of another resource into the output content of the current JSP page. This introduction method during JSP page execution is called dynamic introduction.

Syntax: <jsp: include page = "relativeURL | <% = expression %>" flush = "true | false"/>

The page attribute is used to specify the relative path of the introduced resource. It can also be obtained by executing an expression.

The flush attribute specifies whether to refresh the output content of the current JSP page to the client before inserting the output content of other resources.

<Jsp: forward> tag

<Jsp: forward> the tag is used to forward requests to another resource.

Syntax: <jsp: forward page = "relativeURL | <% = expression %>"/>

The page attribute is used to specify the relative path of the resource to which the request is forwarded. It can also be obtained by executing an expression.

<Jsp: param> label

When you use the <jsp: include> and <jsp: forward> labels to introduce or forward requests to other resources, you can use the <jsp: param> label to pass parameters to this resource.

Syntax 1: <jsp: include page = "relativeURL | <% = expression %>">

<Jsp: param name = "parameterName" value = "parameterValue | <% = expression %>"/>

</Jsp: include>

Syntax 2: <jsp: forward page = "relativeURL | <% = expression %>">

<Jsp: param name = "parameterName" value = "parameterValue | <% = expression %>"/>

</Jsp: include>

<Jsp: param> the name attribute of the tag is used to specify the parameter name, and the value attribute is used to specify the parameter value. You can use multiple <jsp: param> tags in the <jsp: include> and <jsp: forward> tags to pass multiple parameters.

<Jsp: include> comparison with include commands

<Jsp: include> tags are dynamically introduced. The two jsp pages involved in the <JSP: include> tag are translated into two servlets, the contents of the two servlets are merged during execution.

The include command is a static introduction. The two JSP pages involved are translated into a servlet, whose content is merged at the source file level.

Whether it is the <jsp: include> label or the include command, they will combine the content of the two JSP pages and output them. Therefore, do not duplicate the HTML global architecture labels on these two pages, otherwise, the content output to the client will be a messy HTML document.

Four domain objects for web Development

Page domain (pageContext) cycle: Current page

It is called the request domain (request) cycle: the request ends.

It is called the session domain (session) cycle: the session ends.

Called the application domain (servletContext) cycle: the entire web application

 

From chenglong0513

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.