This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Ramesh, first of all JSP isn't place to write your application logic. It is considered as bad practice.
Regarding your exception problem -
You can't be absolutely sure of which exception your JSP is throwing. You'll always get java.lang.SQLException in every case as you are explicitly throwing it from your code. Try to print the stack trace to get the exact exception.