Forums Register Login

Expression Language

+Pie Number of slices to send: Send
I have a piece of code in a JSP



Why I try to run this example I get a NumberFormatException. Part of the log is as follows:

java.lang.NumberFormatException: For input string: "listIdx"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Long.parseLong(Long.java:403)
at java.lang.Long.valueOf(Long.java:518)
at com.sun.el.lang.ELArithmetic$LongDelegate.coerce(ELArithmetic.java:205)
at com.sun.el.lang.ELArithmetic.coerce(ELArithmetic.java:373)
at com.sun.el.lang.ELArithmetic.add(ELArithmetic.java:255)
at com.sun.el.parser.AstPlus.getValue(AstPlus.java:57)
at com.sun.el.parser.AstBracketSuffix.getValue(AstBracketSuffix.java:54)
at com.sun.el.parser.AstValue.getValue(AstValue.java:133)
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:206)
at org.apache.jasper.runtime.PageContextImpl.evaluateExpression(PageContextImpl.java:1001)
at org.apache.jsp.redirect_jsp._jspService(redirect_jsp.java:86)

..

Can someone tell me why it is trying to convert 'listIdx' to Long? I tried another example on the similar lines and it was using Double instead of Long. I dont understand what EL does...
+Pie Number of slices to send: Send
I think it should be


+Pie Number of slices to send: Send
Thanks Mate, I knew that, I wanted to know what it does in the case that I have posted.
+Pie Number of slices to send: Send
This is a result of how the + operator works (details in section JSP.2.3.5.1 of the JSP 2.0 spec.). Basically, since you've got String + Long, an attempt will be made to coerce the String to a Long and then apply the operator.
It would give a normal human mental abilities to rival mine. To think it is just a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1608 times.
Similar Threads
Trouble understanding evaluation of EL string literal
Pg. 420 - Q.6 of HF book
Doubt in HFSJ page-420
Doubt in mock question on page no. 433 of Head First Servlets & JSP 2nd edition Chapter 8
Question on EL
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 20:05:23.