1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.jetty.osgi.httpservice;
20
21 import java.io.IOException;
22
23 import javax.servlet.ServletException;
24 import javax.servlet.http.HttpServletRequest;
25 import javax.servlet.http.HttpServletResponse;
26
27 import org.eclipse.jetty.server.Request;
28 import org.eclipse.jetty.servlet.ErrorPageErrorHandler;
29
30
31
32
33
34
35 public class HttpServiceErrorPageErrorHandler extends ErrorPageErrorHandler
36 {
37
38 private static HttpServiceErrorPageErrorHandler INSTANCE;
39
40 public static HttpServiceErrorPageErrorHandler getInstance()
41 {
42 return INSTANCE;
43 }
44
45 public HttpServiceErrorPageErrorHandler()
46 {
47 INSTANCE = this;
48 }
49
50 @Override
51 public void handle(String target, Request baseRequest,
52 HttpServletRequest request, HttpServletResponse response)
53 throws IOException {
54 if (HttpServiceErrorHandlerHelper.getCustomErrorHandler() != null)
55 {
56 try
57 {
58 HttpServiceErrorHandlerHelper.getCustomErrorHandler().service(request, response);
59 }
60 catch (ServletException e)
61 {
62
63 }
64 }
65 if (!response.isCommitted())
66 {
67 super.handle(target, baseRequest, request, response);
68 }
69 }
70
71 @Override
72 protected void doStop() throws Exception
73 {
74 INSTANCE = null;
75 super.doStop();
76 }
77
78
79
80 }