1 4 package com.opensymphony.module.sitemesh.filter; 5 6 import javax.servlet.RequestDispatcher ; 7 import javax.servlet.ServletException ; 8 import javax.servlet.ServletRequest ; 9 import javax.servlet.ServletResponse ; 10 import java.io.IOException ; 11 12 21 public class RequestDispatcherWrapper implements RequestDispatcher { 22 private RequestDispatcher rd = null; 23 private boolean done = false; 24 25 public RequestDispatcherWrapper(RequestDispatcher rd) { 26 this.rd = rd; 27 } 28 29 public void forward(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException , IOException { 30 if (!done) { 31 include(servletRequest, servletResponse); 32 done = true; 33 } 34 else { 35 throw new IllegalStateException ("Response has already been committed"); 36 } 37 } 38 39 public void include(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException , IOException { 40 if (!done) { 41 rd.include(servletRequest, servletResponse); 42 } 43 else { 44 throw new IllegalStateException ("Response has already been committed"); 45 } 46 } 47 } | Popular Tags |