Tag files in JSP 2.0+ and JSP fragment technology

Source: Internet
Author: User

Soon after entering the new company, today in the project to see the use of the. tag file. At first I thought this was a third party template technology similar to Freemarker. Asked the other team members of the project, originally this is jsp2.0 since the JSP fragment technology. Never used to do projects in such a way, to use the use of JSP in the Include and Jsp:include way. In fact, JSP fragment also has the role of include, but it is more like Third-party Sitemesh technology, for Web page layout and decoration, can be the content of the page and the structure of the page to separate, so as to achieve the purpose of sharing page structure. The following example shows how to use JSP fragment.

Official e-Text Reference document Http://docs.oracle.com/javaee/5/tutorial/doc/bnama.html

DEMO

1 first in the project's Web-inf/tags file, create a new Tpl.tag file that reads

<%@ tag language= "java" pageencoding= "UTF-8"%> <%@ attribute name= "title"%> <%@ attribute name= "TPL1" fra Gment= "true" required= "true"%> <%@ attribute name= "TPL2" fragment= "true" required= "true"%> attribute Name= "Tpl3" fragment= "true" required= "true"%> DOCTYPE html>  

2 Creating index.jsp Files

<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "pageencoding=" UTF-8 "%> <%@ taglib prefix=" Xjo "tagdir="/web-inf/tags "%> <xjo
: TPL title= "Use of JSP tag files" >
    <jsp:attribute name= "TPL1" >
        

3 Access to index.jsp page, the effect is as follows

This column more highlights: http://www.bianceng.cn/webkf/JSP/

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.