111111copyright22 & Copy; garbled Chinese characters!
<% = 1 + 1 %>
< BR />
1 + 2 = $ { 1 + 2 }
Simple tag
Package Tags;
Import Java. Io. ioexception;
Import Java. util. date;
Import Javax. servlet. jsp. jspexception;
Import Javax. servlet. jsp. tagext. simpletagsupport;
Public Class Datetimetag Extends Simpletagsupport {
@ Override
Public Void Dotag () Throws Jspexception, ioexception {
Date dt = New Date ();
This . Getjspcontext (). getout (). println ( " Current Time " + DT );
}
}
<? XML version = "1.0" encoding = "UTF-8" ?>
<! Doctype taglib
Public "-// Sun Microsystems, Inc. // dtd jsp tag library 1.2 // en"
Http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd" >
< Taglib >
< Tlib-version > 1.0 </ Tlib-version >
< JSP-version > 1.2 </ JSP-version >
< Short-name > Custom_dt </ Short-name >
< Uri > /Mycustomtags </ Uri >
< Display-name > My custom </ Display-name >
< Description > This is my custom tag for testing </ Description >
< Tag >
< Name > Cus_now </ Name >
< Tag-class > Tags. datetimetag </ Tag-class >
< Body-content > Empty </ Body-content >
< Description > Show current time
</ Description >
</ Tag >
</ Taglib >
<% @ Taglib prefix = "tags" tagdir = "/WEB-INF/tags" %> <% @ taglib prefix = "C" uri = "http://java.sun.com/jstl/core_rt" %> <% @ taglib URI = "/WEB-INF/customtag. TLD "prefix =" Cus "%>... <body>... <tags: Copyright> </tags: Copyright> <HR/> <Cus: cus_now/> </body>