1 25 29 package org.jresearch.gossip.actions.user.avatar; 30 31 import java.io.IOException ; 32 33 import javax.servlet.ServletOutputStream ; 34 import javax.servlet.http.HttpServletRequest ; 35 import javax.servlet.http.HttpServletResponse ; 36 37 import org.apache.struts.action.ActionForm; 38 import org.apache.struts.action.ActionForward; 39 import org.apache.struts.action.ActionMapping; 40 import org.jresearch.gossip.IConst; 41 import org.jresearch.gossip.actions.BaseAction; 42 import org.jresearch.gossip.configuration.Configurator; 43 import org.jresearch.gossip.dao.ForumDAO; 44 import org.jresearch.gossip.exception.JGossipException; 45 import org.jresearch.gossip.exception.SystemException; 46 import org.jresearch.gossip.forms.ProcessUserForm; 47 48 52 public class ShowAvatarAction extends BaseAction { 53 54 62 protected ActionForward process(ActionMapping mapping, ActionForm form, 63 HttpServletRequest request, HttpServletResponse response) 64 throws JGossipException { 65 if (!Configurator.getInstance().getBoolean(IConst.CONFIG.ENABLE_AVATAR)) { 66 return (mapping.findForward(IConst.TOKEN.DENIED)); 67 } 68 ProcessUserForm puForm = (ProcessUserForm) form; 69 ForumDAO dao = ForumDAO.getInstance(); 70 response.setContentType(IConst.JSP.JPG_CONTENT_TYPE); 71 response.setHeader("Pragma", "no-cache"); 72 response.setHeader("Cache-Control", "no-cache"); 73 response.setDateHeader("Expires", 0); 74 try { 75 ServletOutputStream out = response.getOutputStream(); 76 byte[] data = dao.getAvatar(puForm.getUid()); 77 out.write(data); 78 } catch (IOException e) { 79 throw new SystemException(e); 80 } 81 return null; 82 } 83 84 } | Popular Tags |