1 package org.springframework.samples.jpetstore.web.struts; 2 3 import javax.servlet.http.HttpServletRequest ; 4 import javax.servlet.http.HttpServletResponse ; 5 6 import org.apache.struts.action.ActionForm; 7 import org.apache.struts.action.ActionForward; 8 import org.apache.struts.action.ActionMapping; 9 10 public abstract class SecureBaseAction extends BaseAction { 11 12 public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { 13 AccountActionForm acctForm = (AccountActionForm) request.getSession().getAttribute("accountForm"); 14 if (acctForm == null || acctForm.getAccount() == null) { 15 String url = request.getServletPath(); 16 String query = request.getQueryString(); 17 if (query != null) { 18 request.setAttribute("signonForwardAction", url+"?"+query); 19 } 20 else { 21 request.setAttribute("signonForwardAction", url); 22 } 23 return mapping.findForward("global-signon"); 24 } 25 else { 26 return doExecute(mapping, form, request, response); 27 } 28 } 29 30 protected abstract ActionForward doExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception ; 31 32 } 33 | Popular Tags |