Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts Taglibs and web.xml

 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Faisal Khan
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gregg,
They are bundled in the struts.jar, so you do not need to declare them in the deployment descriptor file.
FK
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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" %>
 
Faisal Khan
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic