Q:

NullPointerException of my SESSION in STRUTS2

After the user logged-in, the user's session is added. And when a user clicks Logout,
it first goes through the interceptor before the action. I don't understand why my session is null after it bypasses my CacheInterceptor.  
CacheInterceptor's purpose is to avoid user to click the back button after he log's off in the application.  
Given this following codes:  
welcome.jsp 
<%@ page language="java" contentType="text/html; charset=US-ASCII"
pageEncoding="US-ASCII"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%if(session.getAttribute("USER") == null){%> <jsp:forward page="login.html"/> <%}%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Welcome Page</title>
</head>
<body>
<h3>Welcome <s:property value="userName"></s:property></h3>

<form action="logout" method="post">
<input value="Logout" type="submit" name="ibm-submit" class="ibm-btn-arrow-pri" />
</form>

</body>
</html>  

struts.xml
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
    "http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
    <constant name="struts.convention.result.path" value="/"></constant>

    <package name="user" namespace="/" extends="struts-default">
        <interceptors>
            <interceptor name="authentication" class="com.ibm.eaylportal.interceptors.AuthenticationInterceptor"></interceptor>
            <interceptor name="noCache" class="com.ibm.eaylportal.interceptors.CacheInterceptor"></interceptor>

            <interceptor-stack name="authStack">
                <interceptor-ref name="authentication"></interceptor-ref>
                <interceptor-ref name="defaultStack"></interceptor-ref>
            </interceptor-stack>

            <interceptor-stack name="authStack">
                <interceptor-ref name="noCache"></interceptor-ref>
                <interceptor-ref name="defaultStack"></interceptor-ref>
            </interceptor-stack>
        </interceptors>

        <default-interceptor-ref name="authStack"></default-interceptor-ref>

        <global-results>
            <result name="login" type="redirect">/login.html</result>
        </global-results>

        <action name="home">
            <interceptor-ref name="defaultStack"></interceptor-ref>
            <result>/login.html</result>
        </action>

        <action name="login" class="com.ibm.eaylportal.actions.LoginAction">
            <interceptor-ref name="defaultStack"></interceptor-ref>
            <result name="success">/welcome.jsp</result>
            <result name="input">/login.html</result>
        </action>

        <action name="logout" class="com.ibm.eaylportal.actions.LoginAction" method="logout">
            <interceptor-ref name="noCache"></interceptor-ref>
            <result>/login.html</result>
        </action>

        <action name="welcome" class="com.ibm.eaylportal.actions.WelcomeAction">
            <result name="success">/welcome.jsp</result>
        </action>

    </package>

</struts>

this is just a part of my ActionClass  
LoginAction.java 
    public String logout(){
        sessionAttributes.remove("USER");
        return SUCCESS;
    }  

CacheInterceptor.java 
public String intercept(ActionInvocation invocation) throws Exception {
        System.out.println("Interceptor: Cache");
        HttpServletResponse response = ServletActionContext.getResponse();

        response.setHeader("Cache-Control", "no-cache");
        response.setHeader("Pragma", "no-cache");
        response.setHeader("Expires", "-1");
        return invocation.invoke();
    }

when the program execution reaches in that sessionAttributes.remove part, it stops the execution because of the NullPointerException.  

A:

something weird happened. the program doesn't have anymore exceptions and it runs successfully. thanks for the help and sorry for the hassle.

