File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes do I have to create a .jar for custom tag ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "do I have to create a .jar for custom tag ?" Watch "do I have to create a .jar for custom tag ?" New topic

do I have to create a .jar for custom tag ?

Frank Sikuluzu
Ranch Hand

Joined: Dec 16, 2003
Posts: 116
I have created

1) WEB-INF/mytag.tld file
2) web.xml: <taglib-uri>/WEB-INF/mytag.tld</taglib-uri>
3) test.jsp: <%@ taglib uri="/WEB-INF/mytag.tld" prefix="test" %>
4) WEB-INF/classes/MyTag.class

and it all works.

But some tutorials/books suggest we create a .jar file including the Tag handler classes, tld, and include the .jar in WEB-INF/lib/, after that for the "uri" part it can either directly points to that .jar or indirectly points to a symbolic name; similarly "taglib-location" can points to that .jar.

My question is -- Is it "required" to follow this step of creating a .jar for the custome tag ? What if I don't create a .jar in WEB-INF/lib ? What problem will my current setting (without a .jar)cause in a production environment ? Although I don't really see any problem with it, I want to confirm as I am not very familiar with custom tag stuff.
Frederic Filiatrault
Ranch Hand

Joined: Jul 12, 2004
Posts: 69

As I experienced, it is only to be distributable. It doesn't affect anything.
But I might be wrong...

F.<br />SCJP, SCJD, SCWCD, SCBCD<br /> <br />Failure is not an option... It comes with the software bundle.
ramprasad madathil
Ranch Hand

Joined: Jan 24, 2005
Posts: 489

Here's and excellent article by BrettMcLaughlin (O'Reilly) on why taglibs ought to be 'jarred' and how to go about it.

It is sorta covered in the JavaRanch Style Guide.
subject: do I have to create a .jar for custom tag ?
It's not a secret anymore!