• Post Reply Bookmark Topic Watch Topic
  • New Topic

Custom Tag problem - Error 500  RSS feed

 
dodo dimitrius
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, guys,
I need help. I've been trying to use a simple tag, but I've been getting Server Error (500)
org.apache.jasper.compiler.CompileException: /st.jsp(8,0) Unable to load class Web-inf.classes.lana
Directory structrure is:
webapps/test/st.jsp
webapps/test/Web-inf/mypage.tld
webapps/test/Web-inf/web.xml
webapps/test/Web-inf/classes/lana.class
Code from st.jsp:
<%@ taglib uri="WEB-INF/mypage.tld" prefix="my"%>
<my:tb>
<%="Hello "%>
</my:tb>
Code from mypage.tld:
<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<short-name>myname</short-name>
<tag>
<name>tb</name>
<tag-class>Web-inf.classes.lana</tag-class>
<body-content>JSP</body-content>
</tag>

</taglib>
Code from web.xml:
<taglib>
<taglib-uri>/mypage.tld</taglib-uri>
<taglib-location>/mypage.tld</taglib-location>
</taglib>
Code form lana.java:
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;
public class lana extends BodyTagSupport {
public int doStartTag() throws JspException {
return EVAL_BODY_INCLUDE;
}
}
Any idea what is wrong?
Berko
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Change your tld to:
<tag-class>lana</tag-class>
 
Simon Brown
sharp shooter, and author
Ranch Hand
Posts: 1913
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might also want to place your tag handler class inside a Java package because of the way that containers translate JSPs into servlets.
Once you've done this, don't forget to reference the fully qualified package name in your TLD file, for example:
<tag-class>myPackage.lana</tag-class>
Hope that helps...
Simon
 
dodo dimitrius
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys for your help!
I tried both options. Simon's option works for me. By the way, I've been using "Professional JSP" to prepare for SCWD exam.
Thanks for the useful links.
Berko
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, change the name of your "Web-inf" directory to "WEB-INF" -- that's what the spec requires... and even if your current app server allows the different case, other app servers won't -- and it will make porting your app in the future easier.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!