response.setHeader("Content-Disposition", "attachment;filename=\"export.csv\"");
//TODO: generate the lenght
response.setContentType("application/x-download");
try {
MailExporter exporter = new MailExporter(new Contact());
OutputStream out = response.getOutputStream();
out.write(exporter.getHeaders().getBytes());
for (Object contact : getSessionBean1().getMailChoices()) {
exporter.setModel(contact);
out.write('\n');
out.write(exporter.getValues().getBytes());
}
out.flush();
out.close();
} catch (IntrospectionException ex) {
error("Error in downloadFile: " + ex.getMessage());