File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Struts Taglibs and web.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Taglibs and web.xml" Watch "Struts Taglibs and web.xml" New topic
Author

Struts Taglibs and web.xml

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

Are the Struts taglibs bundled in the struts.jar file or do I still have declare them in the web.xml file using J2EE 1.4?


GenRocket - Experts at Building Test Data
Faisal Khan
Ranch Hand

Joined: Jun 29, 2003
Posts: 285
Gregg,
They are bundled in the struts.jar, so you do not need to declare them in the deployment descriptor file.
FK


The secret to creativity is knowing how to hide your sources.
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Using Websphere, the tlds get added to web.xml automatically. I took them out and restarted my server. Sure enough, it still works.
I think this is because the declaration script tags in your jsps tell the container where to find them.
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
You could still use the web.xml to alias the tlds...
<taglib>
<taglib-uri>struts-html</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<%@ taglib uri="struts-html" prefix="html" %>


A good workman is known by his tools.
Faisal Khan
Ranch Hand

Joined: Jun 29, 2003
Posts: 285
Originally posted by Marc Peabody:
Using Websphere, the tlds get added to web.xml automatically. I took them out and restarted my server. Sure enough, it still works.
I think this is because the declaration script tags in your jsps tell the container where to find them.
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
You could still use the web.xml to alias the tlds...
<taglib>
<taglib-uri>struts-html</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<%@ taglib uri="struts-html" prefix="html" %>


Marc,
You don't actually need any of the tld files inside your WEB-INF directory as they come packed in the struts.jar file. Furthermore, you don't need to define the tlds as you have above, you can simply have the following line:
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
This will find the tags-html from within the jar file sitting in your /WEB-INF/lib directory
HTH
FK
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Sorry, I lent my own preferences into suggestions.
If I can remember WHY I do it this way... I believe it was because I wanted to run code on a stand-alone box. The more common method would not allow me. If you have deeper insight to this I wouldn't mind learning a thing or two.
You are 100% correct, Faisal. I can't argue with you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts Taglibs and web.xml