tomsky tomsky - 23 days ago 6
Java Question

jstl output doesn't work

I'm working on making an application (developed for tomcat 5.5) to be compatible with tomcat 7 (7.0.27). I'm having problems with jstl, simply tags are not output when I specify:

<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_3_0.xsd"
version="3.0">


in my WEB-INF/web.xml file (previously, the 2.4 version was used).

An example .jsp file:

%@page
language="java"
pageEncoding="utf-8"
contentType="text/html;charset=utf-8"
buffer="none"
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="uri:path-to-layout/layout" prefix="layout" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<fmt:bundle basename="com.path.to.resources.Labels">


...

<td><input
name="j_username"
id="j_username"
maxlength="30"
accesskey="2"
type="text"
style="width: 150px;"
value="<c:out value="${pageContext.request.remoteUser}" default="" />" /></td>


Instead of expected output, I receive:

${pageContext.request.remoteUser}


as the value in the text field.

I use JSTL 1.2.1, Tomcat 7.0.27, JSP 2.2. The code compiles, and when I change web-app version in web.xml from 3.0 to 2.4 it works without outputting those values directly (although there are other issues which force me to use 3.0 version). Any ideas what could be the cause of this problem?

Answer

You mentioned that you were using JSTL 1.2.1, which I assume to be the following ones which are hijacked from the Glassfish server:

  • javax.servlet.jsp.jstl-1.2.1.jar
  • javax.servlet.jsp.jstl-api-1.2.1.jar

However, as per the comments you seem to still have the old JSTL 1.0/1.1 libraries among the 117 files in the /WEB-INF/lib:

  • jstl.jar
  • standard.jar

That would only have conflicted. Remove them.