public void service(ServletRequest req, ServletResponse res)
throws ServletException, IOException
{
CauchoRequest request;
CauchoResponse response;
ResponseAdapter resAdapt = null;
if (req instanceof CauchoRequest)
request = (CauchoRequest) req;
else
request = RequestAdapter.create((HttpServletRequest) req, _webApp);
if (res instanceof CauchoResponse)
response = (CauchoResponse) res;
else {
resAdapt = ResponseAdapter.create((HttpServletResponse) res);
response = resAdapt;
}
Page page = null;
try {
page = getPage(request, response);
if (page == null) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
page.service(request, response);
}
catch (JspParseException e) {
if (e.getErrorPage() != null)
forwardErrorPage(request, response, e, e.getErrorPage());
else
throw new ServletException(e);
}
catch (ClientDisconnectException e) {
throw e;
}
catch (Throwable e) {
if (page != null && page.getErrorPage() != null &&
forwardErrorPage(request, response, e, page.getErrorPage())) {
}
else if (e instanceof IOException) {
log.log(Level.FINE, e.toString(), e);
throw (IOException) e;
}
else if (e instanceof ServletException) {
log.log(Level.FINE, e.toString(), e);
throw (ServletException) e;
}
else {
log.log(Level.FINE, e.toString(), e);
throw new ServletException(e);
}
}
if (resAdapt != null) {
resAdapt.close();
ResponseAdapter.free(resAdapt);
}
}