1 18 19 package org.apache.struts.actions; 20 21 import javax.servlet.ServletException ; 22 import javax.servlet.http.HttpServletRequest ; 23 import javax.servlet.http.HttpServletResponse ; 24 25 import org.apache.commons.logging.Log; 26 import org.apache.commons.logging.LogFactory; 27 import org.apache.struts.Globals; 28 import org.apache.struts.action.Action; 29 import org.apache.struts.action.ActionForm; 30 import org.apache.struts.action.ActionForward; 31 import org.apache.struts.action.ActionMapping; 32 import org.apache.struts.util.MessageResources; 33 import org.apache.struts.util.ModuleUtils; 34 35 55 public class SwitchAction extends Action { 56 57 58 60 61 64 protected static Log log = LogFactory.getLog(SwitchAction.class); 65 66 67 70 protected static MessageResources messages = 71 MessageResources.getMessageResources 72 ("org.apache.struts.actions.LocalStrings"); 73 74 75 77 78 public ActionForward execute(ActionMapping mapping, 80 ActionForm form, 81 HttpServletRequest request, 82 HttpServletResponse response) 83 throws Exception { 84 85 String page = request.getParameter("page"); 87 String prefix = request.getParameter("prefix"); 88 if ((page == null) || (prefix == null)) { 89 String message = messages.getMessage("switch.required"); 90 log.error(message); 91 throw new ServletException (message); 92 } 93 94 ModuleUtils.getInstance().selectModule(prefix, request, getServlet().getServletContext()); 96 97 if (request.getAttribute(Globals.MODULE_KEY) == null) { 98 String message = messages.getMessage("switch.prefix", prefix); 99 log.error(message); 100 throw new ServletException (message); 101 } 102 103 return (new ActionForward(page)); 105 106 } 107 108 109 } 110 | Popular Tags |