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