View Javadoc

1   package org.jmonit.web;
2   
3   import java.io.IOException;
4   
5   import javax.servlet.http.HttpServletResponse;
6   import javax.servlet.http.HttpServletResponseWrapper;
7   
8   /**
9    * @author ndeloof
10   */
11  final class MonitoredHttpServletResponse
12      extends HttpServletResponseWrapper
13  {
14      private int status = HttpServletResponse.SC_OK;
15  
16      /**
17       * @param response
18       */
19      MonitoredHttpServletResponse( HttpServletResponse response )
20      {
21          super( response );
22      }
23  
24      public void setStatus( int sc )
25      {
26          super.setStatus( sc );
27          status = sc;
28      }
29  
30      public void setStatus( int sc, String sm )
31      {
32          super.setStatus( sc, sm );
33          status = sc;
34      }
35  
36      public void sendError( int sc )
37          throws IOException
38      {
39          super.sendError( sc );
40          status = sc;
41      }
42  
43      public void sendError( int sc, String msg )
44          throws IOException
45      {
46          super.sendError( sc, msg );
47          status = sc;
48      }
49  
50      public void sendRedirect( String location )
51          throws IOException
52      {
53          super.sendRedirect( location );
54          status = HttpServletResponse.SC_MOVED_TEMPORARILY;
55      }
56  
57      /**
58       * @return the status
59       */
60      public int getStatus()
61      {
62          return status;
63      }
64  }