@Override protected void handleOnException( Throwable ex, HttpServletRequest request, HttpServletResponse response) { super.handleOnException(ex, request, response); Logger.getLogger(ForwarderServlet.class.getName()) .log( Level.WARNING, "Error when forwarding request: {0} {1}", new Object[] {ex.getMessage(), Arrays.toString(ex.getStackTrace())}); }
/** @return true if the request was served. */ private boolean proxyRemoteUrl( HttpServletRequest req, HttpServletResponse resp, final URL mappedURL, boolean failEarlyOn404) throws IOException, ServletException, UnknownHostException { ProxyServlet proxy = new RemoteURLProxyServlet(mappedURL, failEarlyOn404); proxy.init(getServletConfig()); try { traceRequest(req); try { proxy.service(req, resp); } catch (NotFoundException ex) { // This exception is only thrown in the "fail early on 404" case, in which case // no output was written and we didn't serve the request. return false; } } finally { proxy.destroy(); } // We served this request return true; }
@Override public void init(ServletConfig config) throws ServletException { super.init(config); }