*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Tag Files Packaged in JAR files. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Tag Files Packaged in JAR files." Watch "Tag Files Packaged in JAR files." New topic
Author

Tag Files Packaged in JAR files.

Kamal Tripathi
Ranch Hand

Joined: Oct 02, 2008
Posts: 86
I have an application "sample"

To test example of TAG files packaged in JAR file, I created /result.jsp





Next I know that TAG file has to be placed in META-INF/tags So I created META-INF folder separately and in META-INF/tags I created

MoreFooter.tag


Next I created META-INF/TLDs, I created metaTag.tld



MANIFEST.MF

Next I created a jar (sample-tld.jar) of this META-INF folder and copied to /sample/WEB-INF/lib.



sample-tld.jar structure

--------tags
----------------MoreFooter.tag
--------TLDs
----------------metaTag.tld
--------MANIFEST.MF


Webapp sample structure

--------result.jsp
--------WEB-INF
----------------lib
------------------------sample-tld.jar
--------META-INF
----------------MANIFEST.MF




Now there are some support servlets which forward my request to this JSP. They are working fine. But when I hit it. This is the output

TRYING TAG FILES
DISPLAYING SOME FOOTER THRU TAG FILES in META-INF. ULTIMATE!!!



But for second line of output I expected it to come out in some color followed by "THIS IS IN META-INF ONCE MORE:"

It seems container is not able to associate "comtags" URI with MoreFooter.tag in the jar.

The only thing I can think of is I might have to put something in the JSP to relate the URI to TAG file.

but

<%@ taglib prefix="comtags" uri="/META-INF/tags" %> doesn't work since it says File "/META-INF/tags" not found

<%@ taglib prefix="comtags" tagdir="/META-INF/tags" %> doesn't work since it says that tagdir should start with /WEB-INF/tags

What am I doing wrong here ???


Kamal Tripathi
SCJP 1.4 90%, SCWCD5 94%, Next SCDJWS--> In Naescent stage. Researching abt exam and material itself.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

sample-tld.jar structure

Where is META-INF ? META-INF and its subdirectories should be in the JAR file.

<uri>comtags</uri>

You should use this uri to access your library :


[My Blog]
All roads lead to JavaRanch
Poonam Agarwal
Ranch Hand

Joined: May 12, 2008
Posts: 323
uri>comtags</uri>

You should use this uri to access your library :
view plaincopy to clipboardprint?
<%@ taglib prefix="comtags" uri="comtags" %>




We need to use tagdir while using tagfiles. but as you deploy your tagfiles as a jar within lib folder, you have to use "uri" attribute corresponde to the <uri></uri> element of the TLD file.
Moreover as Cristophe already mentions it. you need to put these files in the META-INF (TLD files AND tag files) folder wirhin simpleTag.jar file. Every .jar has its own META-INF folder inside it.



Thanks <br />Poonam Agarwal SCWCD 86%
Kamal Tripathi
Ranch Hand

Joined: Oct 02, 2008
Posts: 86
I think I didn't put up the sample-tld.jar structure correctly. I missed out on mentioning META-INF. All the contents are inside META-INF. So this is the correct structure.


sample-tld.jar structure

--------META-INF
----------------MANIFEST.MF
----------------tags
------------------------MoreFooter.tag
----------------TLDs
------------------------metaTag.tld

You should use this uri to access your library :



But I didn't have this line in my jsp. (Didn't know that when tag files are packages in jar files you have to use uri attribute instead of tagidr). So now my jsp reads as




But now I am getting error as



I am wondering if I have to declare anything in sample-tld.jar/META-INF/META-INF.MF ???
nisha chidella
Ranch Hand

Joined: Jul 24, 2008
Posts: 57
did you resolve this problem ? am getting the same exception.


SCJP 5.0(100%)
Preparing for SCWCD
Kamal Tripathi
Ranch Hand

Joined: Oct 02, 2008
Posts: 86
nope I was not able to.
nisha chidella
Ranch Hand

Joined: Jul 24, 2008
Posts: 57
Oh ..its working for me now. i just forgot to restart the server after deploying the jar file.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tag Files Packaged in JAR files.
 
Similar Threads
taglib directive for tag files
Tag files inside a JAR.
Tag files in jar...how??
Tag Files
tagdir attribute