It would seem the best way to do this would be to first save the HTML on the server as a txt file and then offer the user a chance to see it as rendered HTML or download the text version. That's the way I'd do it anyways. You could have a garbage sweeper running every hour or so to clean up old files.
public void doGet(HttpServletRequest req, HttpServletResponse res)throws IOException
{
String fname=req.getParameter("fname");
String folder1=req.getParameter("folder");
String folder=folder1+"/"+fname+".pdf";
res.setContentType("application/octet-stream");
ServletOutputStream stream = res.getOutputStream();
BufferedInputStream fif =
new BufferedInputStream(new FileInputStream(folder));
int data;
while((data = fif.read()) != -1) {
stream.write(data);
}PrintWriter out = res.getWriter();
fif.close();
stream.close();
}