• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Why NumberFormatException?

 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a jsp page in which I enter age.

I am getting the value from jsp into servlet by



But now while running I am getting exception of NumberFormatException

when I enter any value into text box of age and press add button of JSP.

Why is that?
Can anybody explain?
 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Possibly you need to trim the age string, as:

 
Rahul P Kumar
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By the way, if you had taken stack trace, you yourself had figured it out the exact reason, or could have shown to us.
 
Jyoti Vaskar
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the reply.

I have added trim() as you said & now its shocking

that I am getting a NullPointerException?? ??

I would like to know about stack trace.

I really don't know about it.
 
Jyoti Vaskar
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have sort out it.
It was the mistake made in jsp page where <form> tag was placed wrongly.

thank you for the help.
 
Rahul P Kumar
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
a null pointer exception shows, that no value is being passed from request.getParameter(). Another debugging method. Take in such cases. In your case it could have quickly shown that there is (no) value being passed. stack trace can be generated from inside catch block. Try searching Exception handling in google, if you are not aware of it.
 
Jyoti Vaskar
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rahul.p Kumar wrote: stack trace can be generated from inside catch block. Try searching Exception handling in google, if you are not aware of it.



I guess you are talking about try catch & finally blocks?

Or it may be System.out.println() about which I am aware of.

I guess stack trace is one & the same thing above, which I am aware of ?

By searching exception handeling I got the same result above !

 
Rahul P Kumar
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes both are pointing to same thing. you print stack trace in catch block. These are common debugging ways, you can use to quickly blame a piece of code
 
Jyoti Vaskar
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rahul.p Kumar wrote:yes both are pointing to same thing. you print stack trace in catch block. These are common debugging ways, you can use to quickly blame a piece of code



Then I am aware of stack trace.

thank you Rahul for the help .
reply
    Bookmark Topic Watch Topic
  • New Topic