關於標籤庫的問題,請求援助

hzyyong發表於2004-04-09
我寫了一個簡單的標籤庫,但出現了一點問題,說是不能解析這個標籤
我的BEAN的程式碼是這樣寫的:
package ATMTag;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;
import java.sql.*;
import java.math.*;
import java.util.*;
public class ATMTag extends TagSupport
{
Connection connect =null;
Statement state = null;
ResultSet result=null;
public ATMTag() throws ClassNotFoundException
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

}
public int doStartTag() throws JspTagException
{
return this.EVAL_BODY_INCLUDE;
}
public int doEndTag() throws JspTagException
{
try
{
JspWriter out = pageContext.getOut();
connect=DriverManager.getConnection("jdbc:odbc:hzy","sa","");

String strQuery="Select cCounter_id,cAddress,mCashBalance from Counter where mCashBalance<=10000";
state=connect.createStatement();
ResultSet result=state.executeQuery(strQuery);
String sId=null;
String sAddress=null;
String sBalance=null;
Vector v=new Vector();

while(result.next())
{
sId=result.getString(1);
sAddress=result.getString(2);
sBalance=result.getString(3);
v.add(sId);
v.add(sAddress);
v.add(sBalance);
}
for(int i=0;i<v.size();i++)
{
String str=(String)v.elementAt(i);
pageContext.getOut().write(str);
}
}
catch(Exception ee)
{
}

return this.EVAL_PAGE;
}
}
這個BEAN以編輯透過。
我的TLD檔案程式碼為:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"

"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<taglib>
<tlibversion>1.0</tlibversion>
<jspversion>1.1</jspversion>
<shortname>ATM</shortname>
<info>A Tag library for the ATM details</info>
<tag>
<name>ATMjsp</name>
<tagclass>ATMTag.ATMTag</tagclass>
<info>Outputs of the ATM counter</info>
<bodycontent>JSP</bodycontent>
</tag>
</taglib>

jsp程式碼為:
<%@ page contentType="text/html;charset=GBK" %>
<%@ page import="ATMTag.ATMTag" %>
<%@ taglib uri="WEB-INF/tld/ATMjsp.tld" prefix="TRS" %>
<%@ page errorPage="errorpage.jsp" %>
<!DocType HTML Public "-//W3c//DTD JSP Tag Library 1.1//EN">
<HTML>
<HEAD>
</HEAD>
<BODY>
<H3 align=center>ATM counters that need Cash</H3>
<table>
<tr><td><TRS:Outline/></td></tr>
</table>
</body>
</HTML>

請各位高手幫我找一個原因,謝謝!!!!!!!

相關文章