• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP Custom Tag - Invalid content was found with element taglib.

 
Dester Raja
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was trying to write my first Custom JSP Tag. When I added the below code in web.xml
I got the below error - Invalid content was found with element taglib.





Also the TagSupport Class is also not recognized. Which jar file has this class ?



Do we need to add Library Jar files ? Please help me resolve this error.
 
Mike Zal
Ranch Hand
Posts: 144
Fedora Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are you using as your example/tutorial? What JSP/Servlet container and version are you using?

Newer versions of the JSP/Servlet containers container do not require the taglib entry in the web.xml since the container will automatically find it.

The jar files that you need to include depends on which container you are using. Usually you should include all jars files in your $CONTAINER_HOME/lib directory in your classpath.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As pointed out, remove the entry from the web.xml. It's not needed.

Either package your tag library as a jar file with the tld in its META-INF folder, or simply places the classes in WEB-INF/classes and put the tld file in WEB-INF. The container will find it on its own.
 
Dester Raja
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using tomcat version 6.0
I am getting the exception TagSupport Cannot be resolved to a type. Which jar file has this class .
I am trying to write my first custom tag code.

public class MyTag extends TagSupport {

}
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
TagSupport is a JSP class. If it's missing it means something is screwed up with your Tomcat installation. Have you remvoed any jar files from its lib folder -- specifically jsp-api.jar?
 
Stefan Evans
Bartender
Posts: 1822
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds more like a compile-time bug than a rug time bug.

So the solution would be to include the jsp-api.jar file from the Tomcat/lib directory into your compile-time classpath.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stefan Evans wrote:Sounds more like a compile-time bug than a rug time bug.

So the solution would be to include the jsp-api.jar file from the Tomcat/lib directory into your compile-time classpath.

Doh! Good catch!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!