Confusion in exception handling in servlet.

Hi to all!

I have got a confusion in exception handling mechanism.

The scenario is:

I am calling a method from a servlet. That method have called some methods that throws some exceptions (actually SQLException).

Then what should I do:-

1. Handle those exceptions in that method only.

2. Pass those exceptions to the servlet (using throws keyword).

Which one is a better approach.

[428 byte] By [Sumit_Tyagia] at [2007-11-27 3:10:49]
# 1

It depends on the main purpose of the method. Generally, if it is just a static utility method, then throw back to the caller. If it is a non-static and/or a "critical" method, then preferably handle or wrap exceptions inside that method. But again, it is just your design choice. Think twice about it, think about reusability and maintainability.

BalusCa at 2007-7-12 8:13:15 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...