• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

SQLException but Servlet continues processing  RSS feed

 
Ranch Hand
Posts: 70
IBM DB2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Author and ninkuma
Marshal
Posts: 66797
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!