Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What JAR files are needed for Eclipse to use JSTL so it ultimately works on GAE/J?

I've been trying for longer than I'd like to admit to get JSTL working under Eclipse (and ultimately under GAE/J). I've downloaded Eclipse, the Google App Engine Extension for Eclipse, and JSTL (http://download.java.net/maven/1/jstl/jars/ - jstl-1.2.jar is in the WEB-INF\lib directory).

My code is below along with the output:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<HTML><HEAD><TITLE>Test Page</TITLE></HEAD><BODY>
Test Page

<c:set var="myvar" value="3"/>

</BODY></HTML>

The error I get is:

The tag handler class for "c:set" (org.apache.taglibs.standard.tag.rt.core.SetTag) was not found on the Java Build Path 
test.jsp
[my app's path and name]
line 8
JSP Problem

From the last post on this page I don't think I need a standard.jar (http://forums.sun.com/thread.jspa?threadID=701267) and in any case I couldn't find one on the Oracle download.java.com site along with the jstl jar.

EDIT 4: Works now - Steps:
1) Use the Apache version
2) Actually include the jar file in the build path (right click the eclipse project and hit Properties -> Java Build Path -> Libraries -> Add Class Folder...; the war/WEB-INF/lib is apparently not on the build path by default)
3) Add the file c.tld to war/WEB-INF/tld

Make your web.xml look like:

<\?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>JSTLExample</display-name>
<welcome-file-list>
    <welcome-file>index.html</welcome-file>
</welcome-file-list>
<jsp-config>
    <taglib>
        <taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
        <taglib-location>/WEB-INF/tld/c.tld</taglib-location>
    </taglib>
</jsp-config>  
</web-app>

The test jsp file contents:

 <?xml version="1.0" encoding="UTF-8" ?>
 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

 <!-- Taglib -->
 <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 <title>Test Apache ServiceMix with JSTL</title>
 </head>
 <body>

 This is a testpage.

 <%= "hello" %>
 <c:forEach var="i" begin="1" end="10" step="1">
 <c:out value="${i}" />

 <br />
 </c:forEach>


 </body>
 </html>
like image 834
user45492 Avatar asked Oct 29 '10 14:10

user45492


1 Answers

I had the same issue and I simply put the prefix = "c" at the end of the taglib definition

before:

<%@ taglib  prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

after:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

And all warnings disappear from Eclipse.

like image 140
user1716015 Avatar answered Nov 09 '22 12:11

user1716015