1 16 17 package org.directwebremoting.util; 18 19 import javax.servlet.RequestDispatcher ; 20 import javax.servlet.ServletRequest ; 21 import javax.servlet.ServletResponse ; 22 23 29 public class FakeRequestDispatcher implements RequestDispatcher 30 { 31 35 public FakeRequestDispatcher(String url) 36 { 37 this.url = url; 38 } 39 40 43 public void forward(ServletRequest request, ServletResponse response) 44 { 45 if (response.isCommitted()) 46 { 47 throw new IllegalStateException ("Cannot perform forward - response is already committed"); 48 } 49 50 if (!(response instanceof FakeHttpServletResponse)) 51 { 52 throw new IllegalArgumentException ("FakeRequestDispatcher requires FakeHttpServletResponse"); 53 } 54 55 ((FakeHttpServletResponse) response).setForwardedUrl(this.url); 56 57 if (log.isDebugEnabled()) 58 { 59 log.debug("FakeRequestDispatcher: forwarding to URL [" + this.url + "]"); 60 } 61 } 62 63 66 public void include(ServletRequest request, ServletResponse response) 67 { 68 if (!(response instanceof FakeHttpServletResponse)) 69 { 70 throw new IllegalArgumentException ("FakeRequestDispatcher requires FakeHttpServletResponse"); 71 } 72 73 ((FakeHttpServletResponse) response).setIncludedUrl(this.url); 74 75 if (log.isDebugEnabled()) 76 { 77 log.debug("FakeRequestDispatcher: including URL [" + this.url + "]"); 78 } 79 } 80 81 private final String url; 82 83 86 private static final Logger log = Logger.getLogger(FakeRequestDispatcher.class); 87 } 88 | Popular Tags |