关于标签库的问题,请求援助

04-04-09 hzyyong
我写了一个简单的标签库,但出现了一点问题,说是不能解析这个标签

我的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>

请各位高手帮我找一个原因,谢谢!!!!!!!

hzyyong
2004-04-09 10:33
> 我写了一个简单的标签库,但出现了一点问题,说是不能解析

> 飧霰昵?> 我的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","s

> ","");

>

> 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.d

> d">

> <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>

>

> 请各位高手帮我找一个原因,谢谢!!!!!!!

huzhigang
2004-04-16 11:15
我的TLD文件代码为:

"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">

1.0

1.1

ATM

A Tag library for the ATM details

ATMjsp

ATMTag.ATMTag

Outputs of the ATM counter

JSP

如果你的tld是这样的。肯定不对

Jackstraw
2004-04-18 16:47
bean好似对的,tld文件贴出来看看,jsp调用应该没问题的吧?!

猜你喜欢