Mohini Dhanaskar wrote:Sir you are right,
i again run the same code ,this time it's not displaying any error but
still while running whole project after feeding values and clicking submit button
it is not calling SuccessfulComplaintRegister.jsp and value is not going to the database
what should i do?
what i understand with above is that-
1. your project gets compiled without errors.
2. You are able to send values through some form you have created and using submit button.
3. After 1 & 2 you get exceptions...
Can you please check your form declaration or any additional request parameters for any thing possibly missing or null.
Have you established the jbdc connection properly?
It seems,when trying to close the connection. Its getting error.
If possible to debug your program, check the value of the variables con & ps.
whether it has values or null.
However, the destroy() method is simple enough to analyse anyway. Do you know what causes a NullPointerException? It happens when you try to call a method on (or similar) a reference that is null. There's only one line in destroy() that can possibly throw one directly:
The exception means that ps is null on this line. The simplest fix that would make the exception go away is to check for this before trying to close it.
But I think there are bigger problems, It's not clear to me why ps isn't local to the doPost() method. As things stand, your servlet is not thread safe, because you might have multiple threads trying to call the same PreparedStatement at the same time. You've got to be very careful using instance variables in servlets, and it's usually a bad idea.