File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes SQLException but Servlet continues processing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "SQLException but Servlet continues processing " Watch "SQLException but Servlet continues processing " New topic

SQLException but Servlet continues processing

Joe Brigs
Ranch Hand

Joined: Jun 06, 2011
Posts: 60

The code below catches my SQl exception as expected, and shows the user an Error JSP Page with some info on it, but the servlet continues and does some other processing. I don't want this other processing to continue. If I add a "return;" as the last line in this snip it of code , it appears to work, but I'm on my own
and I need to know if this is the way to accomplish this ? And what does "return;" actually do in this case ? Thanks

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60804

Please use proper indentation when posting code.

You haven't been clear on what's happening that you're not expecting. Sure if you handle the exception then procession will contain as normal. That's just standard Java.

Backing up a bit, I would not be handling the exception in the servlet in this manner. Rather, I'd wrap the exception in a ServletException and let it propagate outward to be handled by a central error handler registered in the deployment descriptor.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: SQLException but Servlet continues processing
Similar Threads
Data Abstract Class & MVC
HttpClient and sendRedirect
bookstore application error..
why the prm continue executing after I put "response.sendRedirect()" ?
Problems with encodeURL