JSP标签有两种实现方法,一种是使用tag 文件,一种是使用tld文件。
1、使用tag文件
    标签名和tag
文件名一致, tag文件为
JSP文件,可以有属性,把JSP页面当JavaBean文件一样使用。
例子:
1)WEB-INF/lib下放置TAG文件:MyTag.tag,那么就有了一个名为MyTag的标签:
class="java" name="code"><%@ tag pageEncoding="UTF-8" %>  
<%@ attribute name="id" required="true" rtexprvalue="true" %>  
<%@ attribute name="webletID" required="true" rtexprvalue="true" %>  
  
<B>JSP TAG ATTRIBUTE GET<B>  
  
<div id="<%=getId() %>" style="border:solid 1px #ff0000">  
    Here, got the attribute value by get method:<%=getWebletID() %>  
    <br>Got the attribute value by variable:<%=webletID %>  
</div>  
  
<script>  
  
</script>  
<br>  
<%@ tag pageEncoding="UTF-8" %>
<%@ attribute name="id" required="true" rtexprvalue="true" %>
<%@ attribute name="webletID" required="true" rtexprvalue="true" %>
<B>JSP TAG ATTRIBUTE GET<B>
<div id="<%=getId() %>" style="border:solid 1px #ff0000">
	Here, got the attribute value by get method:<%=getWebletID() %>
	<br>Got the attribute value by variable:<%=webletID %>
</div>
<script>
</script><br>
    可定义属性attribute,有变量名(name),是否必需(required)等属性,相当于定义一个JavaBean的属性。在使用属性的值时,可通过get方法来访问或通过变量名的方式来访问。
2)创建引用标签的JSP文件test.jsp,放置于Web目录下,如何WEB-INF同级目录
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>  
<%@ taglib prefix="mx" tagdir="/WEB-INF/tags"%>  
<html>  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=GBK" />  
    <title>Tag test</title>   
</head>  
  
<body>  
    <h1>Tag Test is ok!</h1>  
  
    <mx:MyTag id="Weblet1" webletID="W1001"/>  
</body>  
  
</html>