01: /*
02: * Created on Apr 12, 2005
03: */
04: package uk.org.ponder.servletutil;
05:
06: import javax.servlet.ServletException;
07:
08: import uk.org.ponder.util.ExceptionUnwrapper;
09:
10: /**
11: * @author Antranig Basman (antranig@caret.cam.ac.uk)
12: *
13: */
14: public class ServletExceptionUnwrapper implements ExceptionUnwrapper {
15: public Throwable unwrapException(Throwable tomunch) {
16: if (tomunch instanceof ServletException) {
17: Throwable target = ((ServletException) tomunch)
18: .getRootCause();
19: if (target != null && target != tomunch) {
20: return target;
21: }
22: }
23: return null;
24: }
25:
26: public boolean isValid() {
27: try {
28: Thread.currentThread().getContextClassLoader().loadClass(
29: "javax.servlet.ServletException");
30: } catch (Exception e) {
31: return false;
32: }
33: return true;
34: }
35:
36: }
|