This project has retired. For details please refer to its Attic page.
NoCacheFilter xref
View Javadoc
1   /*
2    * Copyright 2014 The Apache Software Foundation.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.apache.juddi.webconsole;
17  
18  import java.io.IOException;
19  import javax.servlet.Filter;
20  import javax.servlet.FilterChain;
21  import javax.servlet.FilterConfig;
22  import javax.servlet.ServletException;
23  import javax.servlet.ServletRequest;
24  import javax.servlet.ServletResponse;
25  import javax.servlet.http.HttpServletResponse;
26  
27  /**
28   *
29   * @author Alex O'Ree
30   */
31  public class NoCacheFilter implements Filter {
32  
33          @Override
34          public void init(FilterConfig fc) throws ServletException {
35  
36          }
37  
38          @Override
39          public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
40                  HttpServletResponse hsr = (HttpServletResponse) res;
41                  hsr.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1.
42                  hsr.setHeader("Pragma", "no-cache"); // HTTP 1.0.
43                  hsr.setDateHeader("Expires", 0); // Proxies.
44                  chain.doFilter(req, res);
45          }
46  
47          @Override
48          public void destroy() {
49  
50          }
51  
52  }