Hello everyone, i have created a jsp. when i click save button, the data is being stored in the corresponding tables at the back end.When i try to see the data and again click save button later, it displays me java lang Null Pointer Exception. i have written output statements also but could not track this exception. Could any one tell me how to avoid this exception?
Sorry if that seems flip, but there's really not much else to say with the scant information you've given. The stack trace should tell you the exact line where the NPE is occurring. From there you should be able to backtrack to find out why you have a null reference that you did not expect
I'm not sure what you mean by "you could not track this exception". Wrap the statement in a try/catch block and post the stack trace. (Of course, you shouldn't be using Java code in a JSP to begin with, but that's a different issue.) In addition to the stack trace, also post the code that's causing it. Otherwise we'll have no clue on how to advise you.
Ping & DNS - updated with new look and Ping home screen widget
Often you will get the exact line number in the JSP where the NullPointerException was thrown. Depending on the server, you might, instead get the line number in the generated servlet code.
Once you find the line number, look in that line for a method being called on an object. If there is only one method call on that line, you've found the object that is null. From there it should be easy to find the bug.
If there is any part of this that you don't understand, ask for clarification. -Ben