JSTL error

Hi i have the following code in my jsp:

<select name="resultsPerPageSelected" size="1" onchange="document.forms['pagination'].submit()">

<c:if test="${pagination.resultsPerPageSelected == 20}">

<option value="20" selected="selected">20</option>

<option value="40">40</option>

<option value="60">60</option>

<option value="0">All</option>

</c:if>

<c:if test="${pagination.resultsPerPageSelected == 40}">

<option value="20">20</option>

<option value="40" selected="selected">40</option>

<option value="60">60</option>

<option value="0">All</option>

</c:if>

<c:if test="${pagination.resultsPerPageSelected == 60}">

<option value="20">20</option>

<option value="40">40</option>

<option value="60" selected="selected">60</option>

<option value="0">All</option>

</c:if>

<c:if test="${pagination.resultsPerPageSelected == 0}">

<option value="20">20</option>

<option value="40">40</option>

<option value="60">60</option>

<option value="0" selected="selected">All</option>

</c:if>

</select>

and i get this error when i try to build my project using ant:

C:\eclipse\workspace\OER\build\jspsource\org\apache\jsp\reports\domainTrafficClassReport_jsp.java:1303: _jspx_meth_c_if_22(javax.servlet.jsp.tagext.JspTag,javax.servlet.jsp.PageContext) in org.apache.jsp.reports.domainTrafficClassReport_jsp cannot be applied to (org.apache.taglibs.standard.tag.rt.core.IfTag,javax.servlet.jsp.PageContext)

[javac] if (_jspx_meth_c_if_22(_jspx_th_c_if_21, _jspx_page_context))

in fact i get 25 such errors. Ive been having some problems integrating jstl into my project. I've succesfully used the <c:forEach tag and the ><c:if tag but seem to run into trouble when i try to use the ><c:when> <c: otherwise> and now this <option> tag.

Anyone any ideas where i'm going wrong here or something i should check to make sure ive done

Any help appreciated.

Cheers,

Joe

[3144 byte] By [imloaded24_7a] at [2007-11-26 14:56:40]
# 1

It lloks like it can not find the pagination object in the pageContext. It looks to me like pagination is actually a request parameter and should be reference like

<c:if test="${param.pagination.resultsPerPageSelected == 40}">

<option value="20">20</option>

<option value="40" selected="selected">40</option>

<option value="60">60</option>

<option value="0">All</option>

</c:if>

tolmanka at 2007-7-8 8:45:22 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

No its a much stranger one than that. simply the choose tag wont work. all the other ones seem to work fine the following wont even work:

<c:choose>

<c:when test="${true}">

hi

</c:when>

<c:otherwise>

bye

</c:otherwise>

</c:choose>

it says: _jspx_meth_c_when_0(javax.servlet.jsp.tagext.JspTag,javax.servlet.jsp.PageContext) in org.apache.jsp.reports.domainTrafficClassReport_jsp cannot be applied to (org.apache.taglibs.standard.tag.common.core.ChooseTag,javax.servlet.jsp.PageContext)

So basically it thinks that javax.servlet.jsp.tagext.JspTag is not compatible with org.apache.taglibs.standard.tag.common.core.ChooseTag but ive looked up the documentation for these and ChooseTag implements JspTag so they should be compatible. I've no idea how the compiler is getting confused over this. and the worst is that all the other tags are working fine. Anyone any idea what could possibly cause this?

Cheers,

Joe

imloaded24_7a at 2007-7-8 8:45:22 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Try this instead:

<c:choose>

<c:when test="${param.p == null}">

hi

</c:when>

<c:otherwise>

bye

</c:otherwise>

</c:choose>

Not 100% but I believe that the c:when test attribute is looking for an expression that evaluates to a boolean value. The statement "true" is not an expression.

tolmanka at 2007-7-8 8:45:22 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

Check to make sure that there is no version confilcts between your JSTL tag namespace declarations, and the version of web.xml

If you are using the latest JSTL1.1 it should read like this:

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

And if you are using Servlet2.4 spec which is required for EL to evaluate you need to modify web-app your web.xml as follows.

<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">

I tried your code with JSTL1.1 , on Servlet2.4 as follows and it worked:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>

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

<html>

<head><title></title></head>

<body>

<c:choose>

<c:when test="${true}">

hi

</c:when>

<c:otherwise>

bye

</c:otherwise>

</c:choose>

</body>

</html>

appy77a at 2007-7-8 8:45:22 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
Make sure that there is not a servlet.jar in WEB-INF/lib. This is generally provided by the container anyway so it should not be needed at deployment time.
charlesra at 2007-7-8 8:45:22 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...