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: ""
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.
Don't use scriptlet tags. It makes JSPs hard to read. You have JSTL, use it.
For instance here is one close replacement:
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.
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.