1 24 package org.riotfamily.website.filter; 25 26 import java.io.IOException ; 27 28 import javax.servlet.FilterChain ; 29 import javax.servlet.ServletException ; 30 import javax.servlet.http.HttpServletRequest ; 31 import javax.servlet.http.HttpServletResponse ; 32 33 import org.riotfamily.common.util.FormatUtils; 34 import org.riotfamily.common.web.filter.HttpFilterBean; 35 36 39 public class ExpiresFilter extends HttpFilterBean { 40 41 private static final String HEADER_EXPIRES = "Expires"; 42 43 private long expiresAfter; 44 45 public void setExpiresAfter(String expires) { 46 this.expiresAfter = FormatUtils.parseMillis(expires); 47 } 48 49 protected void filter(HttpServletRequest request, HttpServletResponse response, 50 FilterChain filterChain) throws IOException , ServletException { 51 52 response.setDateHeader(HEADER_EXPIRES, 53 System.currentTimeMillis() + expiresAfter); 54 55 filterChain.doFilter(request, response); 56 } 57 58 } 59 | Popular Tags |