• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

mysterious NumberFormatException/Urgent

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps your parameter has a space...?
 
Jo Lee
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Jo Lee
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
reply
    Bookmark Topic Watch Topic
  • New Topic