File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Can't add  taglib element to web.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Can Watch "Can New topic

Can't add taglib element to web.xml

Schandha Ravi
Ranch Hand

Joined: Oct 20, 2007
Posts: 167
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.

Thanks & Regards, SK
SCJP 5.0, DB2 - 800, DB2 - 803, SCDJWS (On the way)
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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.

Consultant, Sima Solutions
Andy Hahn
Ranch Hand

Joined: Aug 31, 2004
Posts: 225
The new recommended way of configuring tag libs are to add the taglib definitions to the top of your JSP like such:
<%@ taglib uri="" prefix="logic" %>
<%@ taglib uri="" prefix="bean" %>
<%@ taglib uri="" prefix="html" %>
<%@ taglib uri="" 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

Joined: Oct 20, 2007
Posts: 167
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

Joined: Feb 15, 2005
Posts: 4864
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.
I agree. Here's the link:
subject: Can't add taglib element to web.xml
Similar Threads
why my application can't detect struts tld files ?
Unable to find taglib in project--please help
JSTL EL language not resolving
EL Configuration Problem