Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting NumberFormatException due to usage of wrong EL syntax

 
karthik chellappan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've a dropdown where i'm trying to display the dropdown values using EL in a c:forEach Loop as shown below :

In the above code, category is a bean class which has following fields:

I'm getting the selected dropdown value in controller servlet as shown below :

When i printed the above line i.e.
i got : instead of selected catID value, which means EL syntax which i'm using to access the catID from category object is wrong.
i tried using the following syntax & by removing "" around EL in 'value' attribute,but both of them didnt work.
Can any one please let me know what is correct usage here?
 
Rob Spoor
Sheriff
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see anything wrong with your syntax. Are you sure that EL is enabled? If you have a web.xml that is specified to use the Servlet 2.3 spec, then EL is disabled by default.
 
karthik chellappan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob,

Servlet version i had was : 2.4
JSP version : 2.0
Server : Apache Tomcat/5.5.27

I saw following in web.xml of the above application:


when i created new web application, the default declaration was of version 2.4 i.e.


I used the above line of code in place of existing code in web.xml and it worked. Thanks for the reply.
 
Rob Spoor
Sheriff
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That version 2.5 should have worked, unless your servlet container (Tomcat?) doesn't support it. Which container do you use?
 
karthik chellappan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob,

I'm using Apache Tomcat/5.5.27.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65223
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just look at the code at the browser with view source. Has the EL been evaluated? If not, that's the problem you need to solve.
 
karthik chellappan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear,

I just changed my root declaration in web.xml to version 2.5 and for my surprise, it worked perfectly fine. I checked source in the browser and saw that EL was evaluated properly which was not happening earlier for version 2.5. When i changed to 2.4 version i didn't get exception (it worked fine) and now i'm not getting exception in 2.5 version as well. So i'm quite confused and not sure why i was getting initially this error.
 
karthik chellappan
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was encountering this problem intermittently and on googling i got below link where they say it could be a bug in Tomcat.

EL

So to avoid this problem i have to include
in jsp page or add in web.xml even though EL is enabled by default for Servlet 2.4 spec and above.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65223
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should never have to put anything on the pages to enable the EL.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic