1 19 20 package com.sslexplorer.navigation.actions; 21 22 import javax.servlet.http.HttpServletRequest ; 23 import javax.servlet.http.HttpServletResponse ; 24 25 import org.apache.struts.action.ActionForm; 26 import org.apache.struts.action.ActionForward; 27 import org.apache.struts.action.ActionMapping; 28 29 import com.sslexplorer.boot.Util; 30 import com.sslexplorer.core.CoreUtil; 31 import com.sslexplorer.core.actions.DefaultAction; 32 import com.sslexplorer.navigation.forms.RedirectForm; 33 import com.sslexplorer.security.Constants; 34 import com.sslexplorer.security.SessionInfo; 35 36 44 public class RedirectAction extends DefaultAction { 45 46 54 public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) 55 throws Exception { 56 super.execute(mapping, form, request, response); 57 String forwardTo = (String ) request.getAttribute(Constants.REQ_ATTR_FORWARD_TO); 58 if (forwardTo == null) { 59 forwardTo = request.getParameter("forwardTo"); 60 if (forwardTo == null) { 61 throw new Exception ("No forwardTo parameter provided."); 62 } 63 } 64 CoreUtil.checkSafeURI(forwardTo); 65 String folder = (String ) request.getAttribute(Constants.REQ_ATTR_FOLDER); 66 if (folder == null) { 67 folder = request.getParameter("folder"); 68 } 69 String target = (String ) request.getAttribute(Constants.REQ_ATTR_TARGET); 70 if (target == null) { 71 target = request.getParameter("target"); 72 } 73 ((RedirectForm) form).init(forwardTo, folder, target); 74 75 String execOnLoad = (String ) request.getAttribute(Constants.REQ_ATTR_EXEC_ON_LOAD); 77 if (execOnLoad != null) { 78 execOnLoad = execOnLoad + " ; setTimeout('doRedirect()', 3000);"; 79 } 80 else { 81 execOnLoad = "javascript: setTimeout('doRedirect()', 3000);"; 82 } 83 request.setAttribute(Constants.REQ_ATTR_EXEC_ON_LOAD, execOnLoad); 84 Util.noCache(response); 85 return mapping.findForward("display"); 86 } 87 88 96 public int getNavigationContext(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { 97 return SessionInfo.ALL_CONTEXTS; 98 } 99 100 } | Popular Tags |