• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Unable to use tag file deployed in jar file

 
Ranch Hand
Posts: 56
Android Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Folks,
I tried using a simple tag file the code of which is given as below

File: field.tag


I called it in a JSP whose code is as below

File: jartagfile.jsp


I put the tag file into a jar file using the command
"jar cvf tagfile.jar ."
I issued this command from the directory that contains META-INF\tags\field.tag. After the command i got the jar file which i placed in WEB-INF\lib

Since this tag file is a part of a jar file, I placed a tag in my TLD as follows:


When I try to access the jartagfile.jsp, I am getting the following exception:


Can anyone tell me whats the problem and how can i resolve it?

Regards
Dinkar
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that you have to put the TLD in the META-INF of the JAR file (but I'm not 100% sure, I've never made JAR packed tag files)
 
Dinkar Chaturvedi
Ranch Hand
Posts: 56
Android Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was wondering if the directive I added in my JSP for the tag file is correct or not.

I read that we must provide the location of the tagfile in the "tagdir" attribute of the directive. Is the way, I have done, the correct way of mentioning the location of the tag file? I mean, how do you indicate the location of a tag file which is inside a jar file?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Dinkar Chaturvedi:
I was wondering if the directive I added in my JSP for the tag file is correct or not.



Of course it's not. That directive is telling the container to look in the WEB-INF/tags folder of the web app, and the tag's not there.

Within the TLD file of the tag library, you would declare the tag like this example:



Note that you can create sub-folders under META-INF. Then place the tag file in the META-INF/whatever folder within the jar file.

Now here's the part that you might be missing: the TLD file for the jarred tag must be within the jar file itself in the META-INF folder.

This way, you can create jar files that are self-contained tag libraries, where there's no need to do anything but drop the jar file (or files as in the case of the JSTL) into the WEB-INF/lib, and then use the appropriate tag declaration on the pages.

You cannot reference the jarred tag file from a TLD that is not in the jar file.
[ April 06, 2007: Message edited by: Bear Bibeault ]
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What would be the appropriate tag declaration?
How would I declare the tag-lib in web.xml if I don't extract the tld file from the library?
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Georges-Etienne Legendre:
How would I declare the tag-lib in web.xml if I don't extract the tld file from the library?



You don't. There is no need for a tag-lib declaration in the web.xml.

What would be the appropriate tag declaration?



The uri attribute of the taglib declaration in the JSP page must match the URI defined within the TLD which will be located within the jar file for the library (in the META-INF folder).

When the jar file is in the calsspath of the app (like in WEB=INF/lib), the container will automatically find it and match it up by URI.
reply
    Bookmark Topic Watch Topic
  • New Topic