I'm getting below error on my Tomcat 5.0.28 while accessing a JSP page(input.jsp) which has below code
Why this error comes. It was all fine some times back and on a sudden it failed.
what could be the reason.
First question is why you are still putting Java scriptlets in JSP pages? That's a practice that is about 6 years out of date at this point.
Your form should be submitting to a servlet controller when your form can be processed and there should be no Java in the JSP.
Even using old-fashioned scriptlets, it's also very strange to have the form processing code in the same JSP as the form. The code will execute before the form even gets sent to the browser for the user to fill in. What sense does that make?
Bear's response contains the information necessary to understand where the NPE's are coming from.
As to why it started to fail, that's hard to say w/o knowing the history of the source: I find it *very* unlikely that the source as presented here *ever* worked--it will always fail when the page is first loaded, before a submit (to the same JSP). (That's another hint.)
I'm curious--code like this would never have survived even a minimal code review anywhere I've worked; is this production code? How has it been tested, and is there an automated testing process in use where the code is developed?