*/
private DataBuffers executeServlet(HTTPRequest request, final Class<? extends SimpleServlet> servletClass) throws HTTPException
{
// servlet found -- full stream ahead </pun>
final ServletResponse servletResponse = new ServletResponse(); // generate a response object
final SimpleServletSession session=getServletSession(request, servletResponse); // get or create a session object
final SimpleServletRequest servletRequest = new ServletRequest(session, request);
try
{
final RequestStats stats = config.getServletMan().getServletStats(servletClass);
final long startTime = System.nanoTime(); // for stat keeping
try
{
stats.startProcessing(); // synchronization is not required, so long as endProcessing is always called
final SimpleServlet servletInstance = servletClass.newInstance(); // instantiate a new servlet instance!
if(request.getMethod() == HTTPMethod.GET)
servletInstance.doGet(servletRequest, servletResponse);
else
if(request.getMethod() == HTTPMethod.POST)
servletInstance.doPost(servletRequest, servletResponse);
servletInstance.service(request.getMethod(), servletRequest, servletResponse);
return servletResponse.generateOutput(request); // the generated output, yea!
}
finally
{
session.touch();
stats.endProcessing(System.nanoTime() - startTime);
lastHttpStatusCode=servletResponse.getStatusCode();
}
}
catch (final HTTPException e)