Article View: cn.bbs.comp.lang.java
Article #22532Re: ��taglib �����⣡
From: ����ͼǿ
Date: Sun, 14 Sep 2003 03:25
Date: Sun, 14 Sep 2003 03:25
108 lines
3756 bytes
3756 bytes
ԭ�ļ���
//DateTag.jsp
<html>
<head>
<title>Professional JSP Tag Libraries</title>
</head>
<%@ taglib uri="/simpleTaglib" prefix="simple" %>
<body>
<h1>The date is <simple:date/></h1>
</body>
</html>
//DateTag.java
package date;
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.tagext.TagSupport;
/**
* A custom tag that displays the current date.
*
* @author Simon Brown
*/
public class DateTag extends TagSupport {
/**
* Called when the starting tag is encountered.
*/
public int doStartTag() throws JspException {
// get the locale of the client and create an appropriate date format
Locale loc = pageContext.getRequest().getLocale();
DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM, loc);
try {
// and write out the formatted date to the page
pageContext.getOut().write(df.format(new Date()));
} catch (java.io.IOException ioe) {
throw new JspTagException(ioe.getMessage());
}
// and skip evaluating the body of the tag (as there shouldn't be one)
return SKIP_PAGE;
}
}
//simple.tld
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!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>simple</short-name>
<description>Examples for the Simple Tags chapter</description>
<tag>
<name>date</name>
<tag-class>date.DateTag</tag-class>
<body-content>empty</body-content>
<description>Inserts the current date into the page</description>
</tag>
</taglib>
web.xml�еIJ���:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<taglib>
<taglib-uri>/simpleTaglib</taglib-uri>
<taglib-location>/WEB-INF/tlds/simple.tld</taglib-location>
</taglib>
<web-app>
3x
�� �� flyingsky (���) �Ĵ������ᵽ: ��
: ��Դ�ļ��������
:
:
: �� �� spideman �Ĵ������ᵽ: ��
: : ��ѧJsp����ѧ��taglibʱ�����������⣡(Ӧ�������ã�ͬ����ļ����˿���ʹ��)
: : Error: 500
: : Location: /examples/DateTag.jsp
: : Internal Servlet Error:
: : org.apache.jasper.compiler.CompileException: C:\tomcat\webapps\examples\Da..
: : g.jsp(10,20) Unable to load class null
: .................������ʡ�ԣ�
--
[m[1;35m�� ��Դ:����ˮ˼Դ bbs.sjtu.edu.cn��[FROM: 211.80.91.167][m
Technical Details
Message-ID:
<48GOTO$A4P@bbs.sjtu.edu.cn>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-01!sn-xit-09!supernews.com!216.170.153.135.MISMATCH!tdsnet-transit!newspeer.tds.net!cyclone.bc.net!logbridge.uoregon.edu!newsgate.cuhk.edu.hk!news.zixia.net!news.neu.edu.cn!SJTUShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,GB X-Google-Thread: f6cb0,d96ae6c83d616cff X-Google-Attributes: gidf6cb0,public X-Google-ArrivalTime: 2003-09-19 03:24:02 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-01!sn-xit-09!supernews.com!216.170.153.135.MISMATCH!tdsnet-transit!newspeer.tds.net!cyclone.bc.net!logbridge.uoregon.edu!newsgate.cuhk.edu.hk!news.zixia.net!news.neu.edu.cn!SJTU From: spideman.bbs@bbs.sjtu.edu.cn (����ͼǿ) Newsgroups: cn.bbs.comp.lang.java Subject: Re: ��taglib �����⣡ Date: 14 Sep 2003 03:25:53 GMT Organization: ��ˮ˼Դ Message-ID: <48GOTO$A4P@bbs.sjtu.edu.cn> Mime-Version: 1.0 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: 8bit X-Filename: Java/M.1063509384.A Lines: 108