3

I want to use html tags in my jsp, so I have to add the tag lib in web.xml when I add these lines to web.xml:

<taglib>
    <taglib-uri>/tags/struts-html</taglib-uri>
    <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>

it does not know taglib tag

Roman C
  • 49,761
  • 33
  • 66
  • 176
AFF
  • 1,515
  • 4
  • 21
  • 35

3 Answers3

5

Newer versions of the JSP/Servlet containers do not require the taglib entry in the web.xml since containers will automatically find it.

You only need the <%@ taglib %> directive in your JSP page for using .tld files:

<%@ taglib prefix="html" uri="/WEB-INF/struts-html.tld" %>
Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
Nirdesh Sharma
  • 734
  • 5
  • 14
3

<taglib> tags must be inside the <jsp-config> tag.

But using Struts2, you absolutely don't need struts-html taglib, it is from Struts 1, which is older, and completely different.

Just take a tour of Struts2 features, and you will discover you don't have to use html-tags anymore, luckily.

Dave Newton
  • 158,873
  • 26
  • 254
  • 302
Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
0

There are three ways to configure the tag-library.

  1. Manual Configuration throw web.xml: Make sure tld files are copy to WEB-INF folder, configure them in web.xml as follow, use the taglib directive attributete in a taglib directive as <%@ taglib uri="mytagliburi" prefix="ww" %>.

.

<taglib>
         <taglib-uri>mytagliburi</taglib-uri>
         <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib> 
  1. Manual Configuration only with taglib directive: Make sure tld files are copy to WEB-INF folder, and configure the directly in taglib directory as <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="ww" %>.
  2. Automatic Configuration: This is the easy way, and used in Struts version 1.2., , just include the struts-taglib.jar in your project classpath or copy it to WEB-INF/lib folder. All the tld details are define inside the struts-taglib.jar\META-INF\tld folder. During deployment, all tlds will deploy automatically. However, we can access it via pre-fixed uri name only. In this method, we are not allow to change the taglib uri name.
Premraj
  • 72,055
  • 26
  • 237
  • 180