/**
* @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 {
// TODO: May want to avoid console noise from 4xx response codes?
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;
}