Hello,

I am trying to develop my own tags. I do not know if this is the right place
to ask but I hope so. The Tag I am developing should read string from a db
and put it in a <select> box on the page. I just can not get it to work and
I am running out of ideas. Please tell me what I am doing wrong. I really
need this code to run. Here comes my code:

package tags;

import javax.servlet.jsp.*;

import javax.servlet.jsp.tagext.*;

import dataconn.*;

/**

* @author Loesekann

*

* To change the template for this generated type comment go to

* Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments

*/

public class DBCombobox extends TagSupport {

private String colum = null;

private String table = null;

private String name = null;

private String css_class = null;

private String def_str = null;

public DBCombobox() {

super();

}

/**

* doStartTag is called by the JSP container when the tag is encountered

*/

public int doStartTag() {

try {

System.out.println("Tag Start\n");

JspWriter page = pageContext.getOut();

page.println("<select size=\"1\" name=" +name+ " class=" +css_class+ ">");

page.println("<option value=''></option>");

tmsDataBean tmsBean = (tmsDataBean)pageContext.findAttribute("tmsBean");

tmsBean.setQuery("select distinct " +colum+ " from " +table);

if(tmsBean.getRecords()){

String Value = null;

while(tmsBean.getNextRecord()){

Value=tmsBean.getColumn(colum);

page.print("<option value='" +Value+"' ");

if(def_str.equals(Value))

page.print(" selected ");

page.print(">" +Value+ "</option>");

}

tmsBean.cleanup();

}

}catch(Exception e) {

System.out.println("doStartTag Exception.\n");

e.printStackTrace();

}

//Must return SKIP_BODY because we are not supporting a body for this

// tag.

return SKIP_BODY;

}


/**

* doEndTag is called by the JSP container when the tag is closed

*/

public int doEndTag(){

try {

JspWriter out = pageContext.getOut();

out.println("</select>");

} catch (Exception e){

System.out.println("doEndTag Exception");

e.printStackTrace();

}

return EVAL_PAGE;

}

/**

* @return

*/

public String getColum() {

return colum;

}

/**

* @return

*/

public String getCss_class() {

return css_class;

}

/**

* @return

*/

public String getDef_str() {

return def_str;

}

/**

* @return

*/

public String getName() {

return name;

}

/**

* @return

*/

public String getTable() {

return table;

}

/**

* @param string

*/

public void setColum(String string) {

colum = string;

}

/**

* @param string

*/

public void setCss_class(String string) {

css_class = string;

}

/**

* @param string

*/

public void setDef_str(String string) {

def_str = string;

}

/**

* @param string

*/

public void setName(String string) {

name = string;

}

/**

* @param string

*/

public void setTable(String string) {

table = string;

}

}



The TLD file looks like this:

<?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>tmstaglib</shortname>

<info>Trinity Tag Libary for eTMS</info>

<!--A Simple tag -->

<tag>

<name>dbcombobox</name>

<tagclass>tags.DBCombobox</tagclass>

<!--Body content can have a value of

empty: no body

JSP: body that is evaluated by container, then possibly processed by the tag

tagdependent: body is only processed by tag; JSP in body is not evaluated.

-->

<bodycontent>empty</bodycontent>

<info>This this combobox tag gets its lines from a db query.</info>

<!-- Optional attributes -->

<attribute>

<name>colum</name>

<required>true</required>

<rtexprvalue>true</rtexprvalue>

</attribute>

<attribute>

<name>table</name>

<required>true</required>

<rtexprvalue>true</rtexprvalue>

</attribute>

<attribute>

<name>name</name>

<required>true</required>

<rtexprvalue>false</rtexprvalue>

</attribute>

<attribute>

<name>css_class</name>

<required>true</required>

<rtexprvalue>true</rtexprvalue>

</attribute>

<attribute>

<name>def_str</name>

<required>true</required>

<rtexprvalue>true</rtexprvalue>

</attribute>

</tag>

</taglib>



My web.xml looks like this:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd";
>
<web-app>
 <context-param>
  <param-name>ENGLISH</param-name>
         <param-value>TRINITY - eTMS - Financial-Management WORLDWIDE
</param-value>
        </context-param>
        <context-param>
            <param-name>GERMAN</param-name>
            <param-value>TRINITY - eTMS - Financial-Management WORLDWIDE
</param-value>
        </context-param>
        <context-param>
            <param-name>FRENCH</param-name>
            <param-value>TRINITY - eTMS - Financial-Management WORLDWIDE
</param-value>
        </context-param>
 <context-param>
  <param-name>SMALL_LOGO</param-name>
  <param-value>images/logo_small.gif</param-value>
 </context-param>
 <context-param>
  <param-name>SMALL_LOGO_WIDTH</param-name>
  <param-value>30</param-value>
 </context-param>
 <context-param>
  <param-name>SMALL_LOGO_HEIGHT</param-name>
  <param-value>27</param-value>
 </context-param>
 <taglib>
  <taglib-uri>/tags/tmstaglib</taglib-uri>
  <taglib-location>/WEB-INF/tmstaglib.tld</taglib-location>
 </taglib>
</web-app>


and in the jsp I inserted this:

<%@ taglib uri="/tags/tmstaglib" prefix="tmstl" %>

<td>

<tmstl:dbcombobox colum="siso" table="TMS_FPVIKLP" name="chf"
css_class="selectboxSmall" def_str="<%=chf%>" />

</td>



The Error Message of  Tomcat 4.1.27 is:

java.lang.NoClassDefFoundError: javax/servlet/jsp/JspContext
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:1647)
        at java.lang.Class.getDeclaredMethods(Class.java:1131)
        at java.beans.Introspector$1.run(Introspector.java:1126)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1124)
        at java.beans.Introspector.getTargetMethodInfo(Introspector.java:989)
        at java.beans.Introspector.getBeanInfo(Introspector.java:370)
        at java.beans.Introspector.getBeanInfo(Introspector.java:144)
        at
org.apache.jasper.compiler.Generator$TagHandlerInfo.(Generator.java:1946)
        at
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:10
93)
        at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:707)
        at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:1028)
        at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:1070)
        at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:1076)
        at org.apache.jasper.compiler.Node$Root.accept(Node.java:232)
        at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:1028)
        at org.apache.jasper.compiler.Generator.generate(Generator.java:1917)
        at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:242)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:369)
        at
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:4
73)
        at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:1
90)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application
FilterChain.java:247)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh
ain.java:193)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja
va:256)
        at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja
va:191)
        at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
        at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180
)
        at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
        at
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.
java:171)
        at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:641)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172
)
        at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:641)
        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java
:174)
        at
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
eNext(StandardPipeline.java:643)
        at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
        at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
        at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
        at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)
        at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne
ction(Http11Protocol.java:392)
        at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
        at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav
a:619)
        at java.lang.Thread.run(Thread.java:534)


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to