1 3 package jodd.madvoc.result; 4 5 import jodd.madvoc.ActionRequest; 6 import jodd.servlet.DispatcherUtil; 7 8 import javax.servlet.RequestDispatcher ; 9 import javax.servlet.http.HttpServletRequest ; 10 import javax.servlet.http.HttpServletResponse ; 11 12 17 public class ServletDispatcherResult extends ActionResult { 18 19 protected static String EXTENSION = ".jsp"; 20 public static final String NAME = "dispatch"; 21 22 public ServletDispatcherResult() { 23 super(NAME); 24 } 25 26 30 public void execute(ActionRequest actionRequest, String resultValue) throws Exception { 31 HttpServletRequest request = actionRequest.getHttpServletRequest(); 32 HttpServletResponse response = actionRequest.getHttpServletResponse(); 33 String target = resultValue + EXTENSION; 34 35 RequestDispatcher dispatcher = request.getRequestDispatcher(target); 36 if (dispatcher == null) { 37 response.sendError(404, "Result '" + target + "' not found"); 38 return; 39 } 40 41 if (DispatcherUtil.isPageIncluded(request, response)) { 44 dispatcher.include(request, response); 45 } else { 46 dispatcher.forward(request, response); 47 } 48 } 49 50 } 51 | Popular Tags |