JSPでEL式が使用できない理由
Hello to all from Spain
Well, my problem is:
I use JSP, LE and a tag library called "Pager Tag Library".
I have a .jsp page with this:
I get an error:
java.lang.NumberFormatException: For input string: "${varNumFilas}"
java.lang.NumberFormatException.forInputString(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
java.lang.Integer.valueOf(Unknown Source)
org.apache.jasper.compiler.JspUtil.coerceToInt(JspUtil.java:796)
...
Always, with any variable...
That is to say, when the required value of the attribute is numeric there is an error, and when the required value is not numeric (an String) there is not an error... ?Why?
Thanks to all
_______________
solve:
So the question is, what server/JSP spec are you using?
If you are using Tomcat 5.x or JSP2.0 spec, then you get EL evaluated outide of JSTL tags by adding:
At the the top of the page.
If you are using an older version of Tomcat, or a server that does not support JSP 2.0, then you will have to re-write the Page Tags to be able to translate EL for you, or not use EL...
Well, my problem is:
I use JSP, LE and a tag library called "Pager Tag Library".
I have a .jsp page with this:
<c:set var="varbool" value="false"/>
<pg:pager items="<%= varNumFilas.intValue() %>"
url="consultatit.do"
index="center"
maxPageItems="5"
maxIndexPages="5"
isOffset="${varbool}"
export="offset,currentPageNumber=pageNumber"
scope="request">
This code works well. No problem. But with...
<c:set var="varNumFilas" value="15"/>
<c:set var="maxpages" value="5"/>
<pg:pager items="${varNumFilas}"
url="consultatit.do"
index="center"
maxPageItems="5"
maxIndexPages="${maxpages}"
isOffset="false"
export="offset,currentPageNumber=pageNumber"
scope="request">
I get an error:
java.lang.NumberFormatException: For input string: "${varNumFilas}"
java.lang.NumberFormatException.forInputString(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
java.lang.Integer.valueOf(Unknown Source)
org.apache.jasper.compiler.JspUtil.coerceToInt(JspUtil.java:796)
...
Always, with any variable...
That is to say, when the required value of the attribute is numeric there is an error, and when the required value is not numeric (an String) there is not an error... ?Why?
Thanks to all
_______________
solve:
So the question is, what server/JSP spec are you using?
If you are using Tomcat 5.x or JSP2.0 spec, then you get EL evaluated outide of JSTL tags by adding:
<%@ page isELIgnored="false" %>
At the the top of the page.
If you are using an older version of Tomcat, or a server that does not support JSP 2.0, then you will have to re-write the Page Tags to be able to translate EL for you, or not use EL...