1 16 17 package org.apache.struts.chain.servlet; 18 19 20 import javax.servlet.RequestDispatcher ; 21 import javax.servlet.http.HttpServletRequest ; 22 import org.apache.commons.chain.Context; 23 import org.apache.commons.chain.web.servlet.ServletWebContext; 24 import org.apache.struts.chain.AbstractPerformForward; 25 import org.apache.struts.config.ForwardConfig; 26 import org.apache.struts.config.ModuleConfig; 27 import org.apache.struts.upload.MultipartRequestWrapper; 28 import org.apache.struts.util.RequestUtils; 29 30 31 37 38 public class PerformForward extends AbstractPerformForward { 39 40 41 43 44 51 protected void perform(Context context,ForwardConfig forwardConfig) 52 throws Exception { 53 54 ServletWebContext swcontext = (ServletWebContext) context; 55 String forwardPath = forwardConfig.getPath(); 56 String uri = null; 57 58 ModuleConfig moduleConfig = (ModuleConfig) context.get(getModuleConfigKey()); 59 if (forwardPath.startsWith("/")) { 61 uri = RequestUtils.forwardURL(swcontext.getRequest(), 62 forwardConfig, 63 moduleConfig); 64 } else { 65 uri = forwardPath; 66 } 67 68 HttpServletRequest request = swcontext.getRequest(); 70 if (request instanceof MultipartRequestWrapper) { 71 request = ((MultipartRequestWrapper) request).getRequest(); 72 } 73 74 if (forwardConfig.getRedirect()) { 76 if (uri.startsWith("/")) { 77 uri = request.getContextPath() + uri; 78 } 79 swcontext.getResponse().sendRedirect 80 (swcontext.getResponse().encodeRedirectURL(uri)); 81 } else { 82 RequestDispatcher rd = 83 swcontext.getContext().getRequestDispatcher(uri); 84 rd.forward(request, swcontext.getResponse()); 85 } 86 87 } 88 89 90 } 91 | Popular Tags |