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

2,146 views
Skip to first unread message

user45492 via StackOverflow

unread,
Nov 2, 2012, 10:42:09 AM11/2/12
to google-appengin...@googlegroups.com

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>


Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/4052552/what-jar-files-are-needed-for-eclipse-to-use-jstl-so-it-ultimately-works-on-gae

BalusC via StackOverflow

unread,
Nov 2, 2012, 10:42:11 AM11/2/12
to google-appengin...@googlegroups.com

Ensure that your web.xml root declaration complies at least Servlet 2.4.

<web-app
    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"
    version="2.4">

    <!-- Config here. -->

</web-app>

Or if your servletcontainer supports it, prefer 2.5:

<web-app 
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    version="2.5">

    <!-- Config here. -->

</web-app>

Otherwise everything will fall back to least supported modus and taglibs may break like that.

Also ensure that you don't have loose tld files wandering around in the classpath (the /WEB-INF/lib folder, among others), they will collide with the ones in JAR files. Oh, also ensure that you didn't manually define the tlds in web.xml, keep it clean.



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/4052552/what-jar-files-are-needed-for-eclipse-to-use-jstl-so-it-ultimately-works-on-gae/4052688#4052688

kukudas via StackOverflow

unread,
Nov 2, 2012, 10:42:13 AM11/2/12
to google-appengin...@googlegroups.com

As far as i know you need jstl.jar and standard.jar. Put those under WEB-INF/lib.



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/4052552/what-jar-files-are-needed-for-eclipse-to-use-jstl-so-it-ultimately-works-on-gae/4052863#4052863

Jubz via StackOverflow

unread,
Nov 2, 2012, 10:42:15 AM11/2/12
to google-appengin...@googlegroups.com

You only need to specify this dependency in your Maven POM:

<dependency>
    <groupId>jstl</groupId>
    <artifactId>jstl</artifactId>
    <version>1.2</version>
</dependency>

In my code, this provided everything I needed for the following JSP taglib to work:

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


Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/4052552/what-jar-files-are-needed-for-eclipse-to-use-jstl-so-it-ultimately-works-on-gae/13197390#13197390
Reply all
Reply to author
Forward
0 new messages