• Post Reply Bookmark Topic Watch Topic
  • New Topic

custom tag question

 
Jian Su
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I am new to custom tag library stuff, trying to make it work but not.
1. I put my datetime.jsp file under C:\Tomcat4\webapps\ROOT\jsp;
2. then .tld file under C:\Tomcat4\webapps\ROOT\WEB-INF folder;
3. and the compiled java DateTimeTag.class file under C:\Tomcat\webapps\ROOT\WEB-INF\classes
I am trying to load jsp file as http://localhost/jsp/DateTime.jsp, but get error message as following. Could anybody please tell me why the JSP CONTAINER CAN'T FIND THE .CLASS FILE?
org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.

An error occurred at line: 5 in the jsp file: /jsp/datetime.jsp
Generated servlet error:
C:\Tomcat4\work\localhost\_\jsp\datetime$jsp.java:59: Class org.apache.jsp.DateTimeTag not found.
DateTimeTag _jspx_th_isspjp_dateTime_0 = new DateTimeTag();
^

An error occurred at line: 5 in the jsp file: /jsp/datetime.jsp
Generated servlet error:
C:\Tomcat4\work\localhost\_\jsp\datetime$jsp.java:59: Class org.apache.jsp.DateTimeTag not found.
DateTimeTag _jspx_th_isspjp_dateTime_0 = new DateTimeTag();
^
2 errors, 1 warning
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:284)
at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:546)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:177)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:189)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1011)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1106)
at java.lang.Thread.run(Thread.java:536)
 
kdjs kdlfw
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should also specify the tag library location in web.xml file by using:
<web-app>
....
<taglib>
<taglib-uri>/WEB-INF/datetime.tld</taglib-uri>
<taglib-location>/WEB-INF/datetime.tld</taglib-location>
</taglib>
....
</web-app>
so that the container could find those tags you have defined.
 
Jian Su
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, kdjs. But it worked the same way. I have put <%@ taglib uri="/WEB-INF/datetime.tld" prefix="date" %> at the beginning of datetime.jsp file, and the container did find .tld file out. But it seems that Tomcat can't find the .class file out. That is weird , as all the .class file should be put in /WEB-INF/classes folder. Why is that the class DateTimeTag can't be found out?
Thanks for the suggestion,
Jian Su
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to place your tag handler class within a package - this should sort it out.
Simon
 
Jian Su
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks so much Simon, you made the point. It is working now.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!