TraderJoeChicago
TraderJoeChicago

Reputation: 6315

Taglib inside Maven dependency jar. How do I configure this taglib inside the web.xml?

So I used to configure my taglib like that:

<jsp-config> 
   <taglib> 
      <taglib-uri>myTags</taglib-uri> 
      <taglib-location>/WEB-INF/lib/mylib-2.0.1.jar</taglib-location> 
   </taglib> 
</jsp-config>

But now mylib-2.0.1.jar is a maven dependency, so of course it is NOT on /WEB-INF/lib.

How do I do to configure my taglib so I can do that in my JSPs:

<%@ taglib uri="myTags" prefix="mt" %>

EDIT1: To clafiry, the taglib.tld is inside the META-INF inside the jar so you can access the tld by referencing the jar itself. That's a convenient way to distribute your taglib along with the web application framework jar.

EDIT2: When we deploy the webapp, the jar will be in the WEB/INF/lib. But during development, inside eclipse, using m2eclipse, the jar will NOT. So eclipse complains it cannot find the taglib no where, because the jar is not there and I cannot reference my jar in the web.xml.

Upvotes: 4

Views: 5113

Answers (2)

Ricardo Jl Rufino
Ricardo Jl Rufino

Reputation: 597

You do not need to configure anything in web.xml, if the taglib is in \META-INF\taglib.tld inside your jar, it is automatic, Tomcat already recognizes.

You can use the jsp :

<% @ Taglib prefix = "my" uri = "http://www.mytags.com/"%>

Upvotes: 3

YMomb
YMomb

Reputation: 2387

If you add in your POM the taglig dependency, it will be added in the WEB-INF/lib directory of your webapp.

  <dependency>
     <groupId>yourTageLib</groupId>
     <artifactId>mylib</artifactId>
     <version>2.0.1</version>
     <scope>compile</scope>
  </dependency>

Upvotes: 2

Related Questions