Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can't add taglib element to web.xml

 
Schandha Ravi
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

my web.xml is based on web-app_2_4.xsd. This web.xml is not supporting <taglib> element. However, if I want to use tlds available through Struts package, I need to include <taglib> element for each tld. How can I accomplish this with this version of web.xml. Also in a book I'm referring to "Beginning Apache Strust - From Novice to Professional" it is mentioned to use web.xml that comes along with Struts ( I have Struts 1.2.7). This web.xml is based on web-app_2_2.dtd which has support for <taglib>.

In my jsp, I want to use


Please let me know how can I add <taglib> to my web.xml which is based on 2.4 xsd.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For a Servlet version 2.4 application, any taglib elements must be enclosed in a <jsp-config> stanza. This is a common mistake because Servlet 2.3 did not require this.
 
Andy Hahn
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The new recommended way of configuring tag libs are to add the taglib definitions to the top of your JSP like such:
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>

The tlds are bundled in the struts jar in Struts1.3.8 so you do not need to configure them in web.xml, thank goodness. I am not sure if they are also bundled in the 1.2.7 struts jar, you will have to check that. If they are not bundled then you are out of luck and will not be able to use the 2.4 xsd.
 
Schandha Ravi
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to both of you.

Andy, actually the tlds are bundled along with struts 1.2.7 package, though not sure if they are bundled in struts.jar. I'll give a try using the recommendations otherwise I shall switch over to 2.2 version
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Struts 1.2.7, The TLDs are not bundled in any of the jar files. You just have to include them in the WEB-INF directory as is done in the struts-blank.war file that comes with the download.

Andy's statement about not being able to use the 2.4 xsd with Struts 1.2.7 is incorrect. As long as you make the taglib declarations properly, it should work fine.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic