Van de Graff
Van de Graff

Reputation: 5163

JSP what taglib should be added?

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.

Upvotes: 1

Views: 11455

Answers (2)

Buhake Sindi
Buhake Sindi

Reputation: 89169

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.

Upvotes: 5

Tomas Narros
Tomas Narros

Reputation: 13468

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

  <taglib>
    <taglib-uri>http://struts.apache.org/tags-html</taglib-uri>
    <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).

Upvotes: 2

Related Questions