/****************************************************************************** * Copyright (c) 1999-2013 Holland America Line Inc. All rights reserved. Use, * disclosure, and reproduction controlled under license from Holland America * Line Inc. ****************************************************************************/ package com.hal.sf.interceptor; import javax.servlet.http.HttpServletResponse; import org.apache.struts2.StrutsStatics; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionInvocation; import com.opensymphony.xwork2.interceptor.Interceptor; /** * This Interceptor instructs web browsers to not cache any content. * *

* Change Log
*

*/ public class CachingHeadersInterceptor implements Interceptor { private static final long serialVersionUID = 1L; /** * Sole constructor */ public CachingHeadersInterceptor() { // empty constructor } /** * Method required by Interceptor interface. */ public void destroy() { // empty method. } /** * Method required by Interceptor interface. */ public void init() { // empty method. } /** * @param actionInvocation * @throws Exception * @return String */ public String intercept(final ActionInvocation actionInvocation) throws Exception { final ActionContext actionContext = actionInvocation.getInvocationContext(); final HttpServletResponse httpServletResponse = (HttpServletResponse) actionContext .get(StrutsStatics.HTTP_RESPONSE); if (httpServletResponse != null) { httpServletResponse.setHeader("Cache-control", "no-cache, no-store"); httpServletResponse.setHeader("Pragma", "no-cache"); httpServletResponse.setHeader("Expires", "-1"); } return actionInvocation.invoke(); } }