1 5 package com.opensymphony.webwork.dispatcher; 6 7 import com.opensymphony.webwork.ServletActionContext; 8 import com.opensymphony.xwork.ActionInvocation; 9 import org.apache.commons.logging.Log; 10 import org.apache.commons.logging.LogFactory; 11 12 import javax.servlet.RequestDispatcher ; 13 import javax.servlet.http.HttpServletRequest ; 14 import javax.servlet.http.HttpServletResponse ; 15 import javax.servlet.jsp.PageContext ; 16 17 18 37 public class ServletDispatcherResult extends WebWorkResultSupport { 38 40 private static final Log log = LogFactory.getLog(ServletDispatcherResult.class); 41 42 44 53 public void doExecute(String finalLocation, ActionInvocation invocation) throws Exception { 54 if (log.isDebugEnabled()) { 55 log.debug("Forwarding to location " + finalLocation); 56 } 57 58 PageContext pageContext = ServletActionContext.getPageContext(); 59 60 if (pageContext != null) { 61 pageContext.include(finalLocation); 62 } else { 63 HttpServletRequest request = ServletActionContext.getRequest(); 64 HttpServletResponse response = ServletActionContext.getResponse(); 65 RequestDispatcher dispatcher = request.getRequestDispatcher(finalLocation); 66 67 if (dispatcher == null) { 69 response.sendError(404, "result '" + finalLocation + "' not found"); 70 71 return; 72 } 73 74 if (!response.isCommitted() && (request.getAttribute("javax.servlet.include.servlet_path") == null)) { 78 request.setAttribute("webwork.view_uri", finalLocation); 79 request.setAttribute("webwork.request_uri", request.getRequestURI()); 80 81 dispatcher.forward(request, response); 82 } else { 83 dispatcher.include(request, response); 84 } 85 } 86 } 87 } 88 | Popular Tags |