File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Getting NumberFormatException due to usage of wrong EL syntax  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Getting NumberFormatException due to usage of wrong EL syntax  " Watch "Getting NumberFormatException due to usage of wrong EL syntax  " New topic
Author

Getting NumberFormatException due to usage of wrong EL syntax

karthik chellappan
Ranch Hand

Joined: Jul 01, 2007
Posts: 31
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?


karthik
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19696
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
karthik chellappan
Ranch Hand

Joined: Jul 01, 2007
Posts: 31
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

Joined: Oct 27, 2005
Posts: 19696
    
  20

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

Joined: Jul 01, 2007
Posts: 31
Rob,

I'm using Apache Tomcat/5.5.27.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61226
    
  66

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
karthik chellappan
Ranch Hand

Joined: Jul 01, 2007
Posts: 31
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

Joined: Jul 01, 2007
Posts: 31
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

Joined: Jan 10, 2002
Posts: 61226
    
  66

You should never have to put anything on the pages to enable the EL.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting NumberFormatException due to usage of wrong EL syntax