Java Reference
In-Depth Information
response.setContentType("application/pdf");
servletOutputStream.flush();
servletOutputStream.close();
}
catch (Exception e)
{
// display stack trace in the browser
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
e.printStackTrace(printWriter);
response.setContentType("text/plain");
response.getOutputStream().print(stringWriter.toString());
}
}
}
We had already discussed this technique in the previous chapter. The only
difference, here, is that we are passing a connection to the report to generate a
database report. After deploying this servlet and pointing the browser to its URL,
we should see a screen like the following:
 
Search WWH ::




Custom Search