From inside a
servlet:
response.setContentType("application/octet-stream");
String name = "test.msg";
response.addHeader("Content-Disposition", "attachment; filename="+name);
String path = "/home/user/msg/" + name;
InputStream input = new FileInputStream(path);
OutputStream out = response.getOutputStream();
int ch;
while ( (ch = input.read()) != -1 ) {
out.write((char) ch);
}