aspose file tools*
The moose likes JSP and the fly likes mysterious NumberFormatException/Urgent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "mysterious NumberFormatException/Urgent" Watch "mysterious NumberFormatException/Urgent" New topic
Author

mysterious NumberFormatException/Urgent

Jo Lee
Ranch Hand

Joined: Jun 26, 2001
Posts: 35
in my jsp pages, I use url to pass some integer parameters.
such as code=5
simple enough
But when the second page try to retrieve that number by
Integer.parseInt(request.getParameter("code"));
it gives me a NumberFormatException.
It only happens on some cases, for example, if I have code=5 and anthcode=6, only code=5 will give me an exception, but anthcode=6 does not.
I deleted the files in the tomcat-4.0.4's directly and restarted tomcat multiple times, and check double checked the difference between code=5 and anthcode=6, I am pulling my hair at the moment by this mystery.
Any help is really appreciated.

Thanks a zillion
Lee
Anthony Villanueva
Ranch Hand

Joined: Mar 22, 2002
Posts: 1055
Perhaps your parameter has a space...?
Jo Lee
Ranch Hand

Joined: Jun 26, 2001
Posts: 35
Thanks Anthony;
I doubled checked the spaces, there is no extra spaces. Another funny thing that it seems other of my java program can not handle Integer.parseInt any more. If I use Integer.parseInt(string), I get a number format exception. It not only occur on one of my computer, it occurs on both of them.
I am really lost.
Kaustubh Patil
Ranch Hand

Joined: Aug 13, 2001
Posts: 164
Hi,
I am not able to detect the exact cause for your problem. But you can try one thing. Type-cast the request.getParameter() in to String before doing a parseInt.
Also chect if the parameter you get is not null. If its null can cause the NumberFormatException.
Kaustubh.


Kaustubh. Mumbai, India.
Jo Lee
Ranch Hand

Joined: Jun 26, 2001
Posts: 35
I find the problem. One of the required int paremeter is missing from one of the links
After I fixed it, it all works now. One of the String parameter has a space missing.
Thanks again
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: mysterious NumberFormatException/Urgent