JSP base syntax four contains directives

Source: Internet
Author: User
Tags contains

What is included:

In the development of the page, some code will inevitably have repeated use of the situation, such as a page has a section of code a,b page and C page can use a this code, then the B and C pages include a page, the natural A This code is also included in the BC page, so that the B, C page can be used to a code, Avoids duplicate write a code.

The meaning of the inclusion:

With the include action, you can include some duplicate code in the continue use.

Generally divided into four regions as above.

The real change is just the content, because depending on the different user browsing, then there are two ways to make sure there's a difference now.

Method One: In the absence of a JSP page (HTML), contains the toolbar, header information, tail information, specific content

Method Two: The tool bar, the head information into each individual file, in the future when the direct guide in

It's clear that the second approach is better than the first, because if you take the first approach, many of the code will have duplicate problems, and if you use the second form, it's convenient to change later.

If you want to implement the included actions in the JSP, there are two ways to do this: static inclusion and dynamic inclusion

Static contains

Let's take a look at a included program

First page info.html

Second page info.jsp

Third page baohan.jsp

<%@ page contenttype= "text/html" pageencoding= "GB2312"%>    

Run the baohan.jsp page to see the contents of the info.html and info.jsp pages, indicating that the contents of info.html and info.jsp pages were successfully included in the Baohan.jsp page.

But the problem is, after we run, click the right mouse button-view the source code, you can find that the static contains is the content of the direct replacement, like the program defined variables, will directly import content into.

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.