Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Input error: NumberFormatException

Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, I'm not good with beans, but I'm trying to patch together code where there is a userid, pass, and usertype. I struggled to get the usertype working correctly, but now it looks like there's something wrong between my update form, my controller, and possibly my database access object.

I think what's going on is that I'm not able to pass the action to the URL, so the controller isn't able to trigger correctly. If that's the problem, I can't figure out how to fix it. You can see in my latest iteration that I've tried passing the variables to the forward string. It doesn't seem to take.

I know it's probably not the best way to do it, but (before you ask) it's for a class and we're coming up to the last few days. I'd appreciate it if you could tell me how to fix it as-is rather than ONLY telling me the "right way". Feel free to tell me the "right way", too, so I can learn for future experience.

The error message I'm getting is:

HTTP Status 500 - Internal Server Error
type Exception report
messageInternal Server Error
descriptionThe server encountered an internal error that prevented it from fulfilling this request.
java.lang.NumberFormatException: For input string: ""




Posts: 1845
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rant #1:
On one hand it is tricky to analyze this code, because there is an awful lot of it.
On the other hand, there are critical bits missed out.
When asking a question like this it helps a lot if you can give a small, self-contained example.
Something that can be copied, pasted and run without any other bits and pieces.

This one fails because you reference some external classes: dao.PreferencesDao and model.Preferences.
The JSPs include a "head.jsp" and a "template.jsp".
These files may or may not be relevant.
If they are relevant, they should be included - I think the model at the least should be there
Otherwise they shouldn't be mentioned.

Rant #2:
Don't use scriptlet tags. It makes JSPs hard to read. You have JSTL, use it.
For instance here is one close replacement:

Rant #3
Can you please provide a bit more information about how you are getting this error message.
What request is being made? Is there a stack trace for this error in the log? What line of code does the root cause trace to?
All of that info is useful in diagnosing a bug.

Solution #1:

Ok, the error message is NumberFormatException for input string "".

So somewhere in your code you are trying to convert a String to a number, and the value for it is empty string.

This line of code is doing a string --> long:

So your value for "userid" is probably coming empty from the page.
That field is defined in your JSP as:

I would suggest
- turning it into a text field temporarily so that you can see if it gets a value or not, and potentially edit it for debugging purposes
- figure out a way to populate it.

That may or may not be the root cause - can't tell without a stack trace. But it looks to be a likely candidate.

good luck,
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic