user359187
user359187

Reputation: 2279

Apache Tomcat restart causes session clear in Java and session persist on a JSP page

I have written a jsp redirect in my jsp page like this

<s:if test="#session.Doctor =  true ">
    <script type="text/javascript">
        top.location.href = "dashboard";
    <s:property value="#session.Doctor" />
    </script>
</s:if>

The tag prints true in my jsp page when I restart Tomcat. But I have written a interceptor in struts which checks the session System.out.println(session.get("doctorLogin")+"test"); and it prints null when I restart the page. Here I could understand that the session is cleared in java when I restart tomcat and session persist in jsp when I restart tomcat. Do anybody have an idea about how this why this session is cleared in java page and why it doesn't in jsp page when restart the tomcat. Does anybody have an idea?

I am using struts2, hibernate and tomcat6 as server

Thanks.

Upvotes: 0

Views: 909

Answers (1)

Sean Reilly
Sean Reilly

Reputation: 21836

Is the test in the if tag broken?

in java, the expression session.Doctor = true doesn't check the value of session.Doctor. Rather, it assigns the value true to session.Doctor.

Try using <s:if test="#session.Doctor == true "> (note the second equals)

Upvotes: 1

Related Questions