| /******************************************************************************* |
| * Copyright (c) 2010-2013 Oracle. All rights reserved. |
| * This program and the accompanying materials are made available under the |
| * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 |
| * which accompanies this distribution. |
| * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html |
| * and the Eclipse Distribution License is available at |
| * http://www.eclipse.org/org/documents/edl-v10.php. |
| * |
| * Contributors: |
| * dclarke - EclipseLink 2.4 - MySports Demo Bug 344608 |
| ******************************************************************************/ |
| package eclipselink.example.mysports.admin.jsf; |
| |
| import java.io.IOException; |
| |
| import javax.faces.application.ResourceHandler; |
| import javax.servlet.Filter; |
| import javax.servlet.FilterChain; |
| import javax.servlet.FilterConfig; |
| import javax.servlet.ServletException; |
| import javax.servlet.ServletRequest; |
| import javax.servlet.ServletResponse; |
| import javax.servlet.annotation.WebFilter; |
| import javax.servlet.http.HttpServletRequest; |
| import javax.servlet.http.HttpServletResponse; |
| |
| @WebFilter(servletNames = { "Faces Servlet" }) |
| public class NoCacheFilter implements Filter { |
| |
| @Override |
| public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { |
| HttpServletRequest req = (HttpServletRequest) request; |
| HttpServletResponse res = (HttpServletResponse) response; |
| // Skip JSF resources (CSS/JS/Images/etc) |
| if (!req.getRequestURI().startsWith(req.getContextPath() + ResourceHandler.RESOURCE_IDENTIFIER)) { |
| // HTTP 1.1. |
| res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); |
| // HTTP 1.0. |
| res.setHeader("Pragma", "no-cache"); |
| // Proxies. |
| res.setDateHeader("Expires", 0); |
| } |
| |
| chain.doFilter(request, response); |
| } |
| |
| @Override |
| public void destroy() { |
| } |
| |
| @Override |
| public void init(FilterConfig arg0) throws ServletException { |
| } |
| } |