tags:

views:

49

answers:

2

What lines starting with <%@ should be added at the beginning of a JSP file to be able to make use of the tag.

I have added the following line to the beginning of my jsp.

<%@ taglib prefix="html" uri="http://struts.apache.org/tags-html" %>

But Eclipse IDE says

The tag handler class for "html:link" (org.apache.struts.taglib.html.LinkTag) was not found on the Java Build Path

next to the < html:link > tag.

What is wrong here?

What I am trying to do is - load page1.jsp from homepage.jsp through struts actionmapping.

+2  A: 

You have to declare it at your web.xml deployment descriptor:

  <taglib>
    <taglib-uri>http://struts.apache.org/tags-html&lt;/taglib-uri&gt;
    <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
  </taglib>

And keep a copy of the TLD file at the location specified there.

Also, you have to check that you have included the struts-taglib.jar on your classpath (the /WEB-INF/lib folder, in this case).

Tomas Narros
I think for an up to date container you don't need to specify it in the web.xml. But you have to put the tld in an appropriate folder. For example under WEB-INF.
kukudas
@kukudas - you don't need to put the TLD file anywhere. The taglibs implementation will find the TLD in the relevant JAR's META-INF directory.
Stephen C
oh right, i remember reading that somewhere. So basicly you just have to take care that the JAR file is on your classpath and that's it or am i wrong?
kukudas
+4  A: 

If you have download the full struts jar, you don't need to declare your taglibs in web.xml.

  1. Download Struts from here. In my case, I've downloaded the struts-1.3.10-all.zip
  2. Copy all the jars from the <zipped file>\struts-1.3.10\lib into your WEB-INF\lib folder (in your project).
  3. At the top of each JSP page that will use JSP tags, add line(s) declaring the JSP tag libraries used on this particular page, like this:

Example:

<%@ 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-logic" prefix="logic" %>

More on the Struts 1.x installation Guide.

The Elite Gentleman