User user = (User) session.getAttribute(IConst.SESSION.USER_KEY);
ForumDAO dao = ForumDAO.getInstance();
ProcessAttachForm paForm = (ProcessAttachForm) form;
if (Configurator.getInstance().getBoolean(
IConst.CONFIG.ENABLE_FILE_UPLOAD)) {
FileData fData = dao
.getAttachment(Integer.parseInt(paForm.getId()));
String mime = fData.getInfo().getContentType();
response.setContentType(mime);
if (!(IConst.JSP.JPG_CONTENT_TYPE.equals(mime)
|| IConst.JSP.GIF_CONTENT_TYPE.equals(mime) || IConst.JSP.PNG_CONTENT_TYPE
.equals(mime))) {
response.setHeader("Content-disposition",
"attachment;filename=\"" + fData.getInfo().getName()
+ "\"");
}
response.addHeader("Content-description", fData.getInfo()
.getDescription());
ServletOutputStream outStream = response.getOutputStream();
outStream.write(fData.getData());
outStream.flush();
outStream.close();
} else {
return (mapping.findForward(IConst.TOKEN.DENIED));
}