<!-- start of taglib declaration my is the reference to the taglib which the
jsp uses to reference JavaScriptExampleTag-->
<tag>
<name>my</name>
<tag-class>JavaScriptExampleTag</tag-class>
<info>Display Alert Box</info>
<attribute>
<name>message</name>
<required>true</required>
<description><![CDATA[Put some message to echo here]]></description>
</attribute>
<attribute>
<name>id</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
<description><![CDATA[id for referencing element. For UI and form tags it
will be used as HTML id attribute]]></description>
</attribute>
<attribute>
<attribute>
<name>name</name>
<required>true</required>
<rtexprvalue>false</rtexprvalue>
<description><![CDATA[..Name ..]]></description>
</attribute>
<attribute>
......
</tag>
<!-- at start of jsp put all of your taglib declarations so the prefix my
associates my to the JavaScriptExampleTag.tld such as what you see below-->
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/tld/JavaScriptExampleTag.tld" prefix="my" name="my"%>
i didnt see the 'message' attribute in your BodyTagSupports declared variables
or an accessor e.g.
public class JavaScriptExampleTag extends BodyTagSupport {
........
//String storage allocation for message
public String message;
//mutator
public void setMessage(String message) {
this.message = message;
}
//accessor
public void getMessage() {
return this.message;
}
.......
}
http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/jsp/tagext/TagInfo.html
implement pidster's advice for everything else..
Martin
______________________________________________
Disclaimer and confidentiality note
Everything in this e-mail and any attachments relates to the official business
of Sender. This transmission is of a confidential nature and Sender does not
endorse distribution to any party other than intended recipient. Sender does
not necessarily endorse content contained within this transmission.
> Date: Sun, 8 Mar 2009 14:20:09 +0000
> From: [email protected]
> To: [email protected]
> Subject: Re: tomcat 6.0.18 issue with my customer Tag class
>
> Mike.G wrote:
> > Hi, everyone,
> > I run the tomcat 6.0.18 on my ubuntu 8.04.2, the jdk version is 1.6.0_07
> >
> > I configure the localhost 's ROOT to my home directory /home/ghw/myjava
> > the configuration file like this:
> >
> > <?xml version='1.0' encoding='utf-8'?>
> >
> > <Server port="8005" shutdown="SHUTDOWN">
> >
> > <Listener className="org.apache.catalina.core.AprLifecycleListener"
> > SSLEngine="on" />
> > <Listener className="org.apache.catalina.core.JasperListener" />
> > <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
> > />
> > <Listener
> > className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
> >
> > <GlobalNamingResources>
> > <Resource name="UserDatabase" auth="Container"
> > type="org.apache.catalina.UserDatabase"
> > description="User database that can be updated and saved"
> > factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
> > pathname="conf/tomcat-users.xml" />
> > </GlobalNamingResources>
> >
> > <Service name="Catalina">
> > <Connector port="8080" protocol="HTTP/1.1"
> > connectionTimeout="20000"
> > redirectPort="8443" />
> > <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
> > <Engine name="Catalina" defaultHost="localhost">
> > <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
> > resourceName="UserDatabase"/>
> > <Host name="localhost" appBase="webapps"
> > unpackWARs="true" autoDeploy="true"
> > xmlValidation="false" xmlNamespaceAware="false">
> >
> > </Host>
> > </Engine>
> > </Service>
> > </Server>
> >
> >
> > and I created the directory understand CATALINE_HOME/conf/Catalina/localhost
> > and create a ROOT.xml in there
> > like this:
> > <?xml version="1.0" encoding="utf-8"?>
> >
> > <Context path="" docBase="/home/ghw/myjava" debug="9" reloadable="9" >
> >
> > </Context>
> >
> > when write a test index.jsp in /home/ghw/myjava, it works.
> >
> >
> > and when I try to write a Tag class in there, it will be report Error:
> >
> > *type* Exception report
> >
> > *message*
> >
> > *description* *The server encountered an internal error () that prevented it
> > from fulfilling this request.*
> >
> > *exception*
> >
> > org.apache.jasper.JasperException: Unable to compile class for JSP:
> >
> > An error occurred at line: 10 in the jsp file: /test.jsp
> > JavaScriptExampleTag cannot be resolved to a type
> > 7: </head>
> > 8: <body>
> > 9: <p>This is a simple test page </p>
> > 10: <my:message>
> > 11: This is a simple java alert message
> > 12: </my:message>
> > 13:
> >
> >
> > An error occurred at line: 10 in the jsp file: /test.jsp
> > JavaScriptExampleTag cannot be resolved to a type
> > 7: </head>
> > 8: <body>
> > 9: <p>This is a simple test page </p>
> > 10: <my:message>
> > 11: This is a simple java alert message
> > 12: </my:message>
> > 13:
> >
> >
> > An error occurred at line: 10 in the jsp file: /test.jsp
> > JavaScriptExampleTag cannot be resolved to a type
> > 7: </head>
> > 8: <body>
> > 9: <p>This is a simple test page </p>
> > 10: <my:message>
> > 11: This is a simple java alert message
> > 12: </my:message>
> > 13:
> >
> >
> > Stacktrace:
> >
> > org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
> >
> > org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
> >
> > org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
> > org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)
> > org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
> > org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
> >
> > org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
> >
> > org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
> > org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
> > org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
> >
> >
> > here is my web.xml
> > <taglib>
> > <taglib-uri>
> > /WEB-INF/tld/JavaScriptExampleTag.tld
> > </taglib-uri>
> >
> > <taglib-location>
> > /WEB-INF/tld/JavaScriptExampleTag.tld
> > </taglib-location>
> > </taglib>
> >
> >
> > and the tld file is like this:
> > <?xml version="1.0" encoding="utf-8"?>
> >
> > <!DOCTYPE taglib
> > PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
> > "http://java.sun.com/j2ee/dtd/web-jsptaglibrary_1_2.dtd">
> >
> > <taglib>
> > <tlib-version>1.0</tlib-version>
> > <jsp-version>1.2</jsp-version>
> > <short-name>JavaScriptExampleTag</short-name>
> > <uri>/WEB-INF/tld/JavaScriptExampleTag.tld</uri>
> > <description>
> > A simple tab library for the examples
> > </description>
> >
> > <tag>
> > <name>message</name>
> > <tag-class>JavaScriptExampleTag</tag-class>
> > <info>Display Alert Box</info>
> > </tag>
> >
> >
> >
> > </taglib>
> >
> >
> > and the Tag class like this:
> > import java.io.IOException;
> > import javax.servlet.jsp.*;
> > import javax.servlet.jsp.tagext.*;
> >
> > public class JavaScriptExampleTag extends BodyTagSupport {
> > public int doEndTag() throws JspTagException {
> > String ls_alert = "";
> >
> > try {
> > BodyContent lbc_bodycurrent = getBodyContent();
> >
> > if ( lbc_bodycurrent != null ) {
> > String ls_message = lbc_bodycurrent.getString();
> > JavaScriptExample JS = new JavaScriptExample();
> >
> > ls_alert = JS.alert(ls_message.trim());
> >
> > }
> >
> > pageContext.getOut().write(ls_alert);
> >
> > } catch ( IOException e ) {
> > throw new JspTagException("Error " + e.toString());
> > }
> > return EVAL_PAGE;
> > }
> > }
>
> Put your tag class in a package, and make sure the tag class is in the
> correct folder like so:
>
> myapp/index.jsp
> myapp/WEB-INF/classes/com/myapp/YourTag.class
> myapp/WEB-INF/tld/YourTag.tld
>
> Adjust the tag class definition in the the TLD accordingly.
>
> p
>
>
>
> > and the Bean class is like this:
> > import java.io.Serializable;
> >
> > public class JavaScriptExample implements Serializable {
> >
> > public JavaScriptExample() {
> >
> > }
> >
> > public String alert(Object aobj_data) {
> > return( start_script + " alert(\" " +
> > aobj_data.toString() + "\");" +
> > end_script );
> > }
> >
> >
> >
> > //private area
> > private String start_script = "<script language=\"javascript\">";
> > private String end_script = "</script>";
> >
> >
> >
> > }
> >
> >
> > anyone can help me on this?
> >
> > thanks very much
> >
> >
> > Mike
> > javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
_________________________________________________________________
Express your personality in color! Preview and select themes for Hotmail®.
http://www.windowslive-hotmail.com/LearnMore/personalize.aspx?ocid=TXT_MSGTX_WL_HM_express_032009#colortheme