This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Expression Language  RSS feed

 
C Shinde
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Srikanth Nalam
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it should be


 
C Shinde
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mate, I knew that, I wanted to know what it does in the case that I have posted.
 
Kris Schneider
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!