if (file == null) {
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return;
}
FileRetrieverConnection connection = null;
try {
connection = getConnection();
response.setContentType("application/x-download");
response.setHeader("Content-Disposition", "attachment; filename=" + file);
connection.retrieve(file, response.getOutputStream());
} catch (FileNotFoundException fnfe) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
} catch (Exception e) {
throw new ServletException(e);
} finally {
if (connection != null) {
try {
connection.close();
} catch (ResourceException re) {
}
}
}
}