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: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org