hazelcast / hazelcast-tomcat-sessionmanager

Tomcat Based Web Session Replication
Other
33 stars 37 forks source link

JSP Session Issues #75

Closed bakedzebra closed 4 years ago

bakedzebra commented 4 years ago

Currently I`m facing an issue with JSP beans property management. Please follow the source code below:

...
<jsp:useBean id="user" class="...User" scope="session"/>
<jsp:useBean id="list" class="...LinkedList" scope="session"/>
...

Previously, all the JSPs were handled by Oracle Weblogic but now I had to migrate the project to Spring Boot with Embedded Tomcat and Hazelcast Session Management. So the issue occurs if we do smth like this:

user.setUsername("test");
list.add(new Object());
response.setRedirect(...);

After the redirect is made I`m trying to reach the username or list values but what I actually receive is:

user.getUsername() => null
list.size() => 0
This one was working using the Weblogic.

Note: But there is a easy but not very effective solution for this issue:

session.putValue("user", user);
session.putValue("list", list);
response.setRedirect(...);

I have a lot of JSP pages so I can`t cover all of this issues. Could you please help me with this one? Thanks!

nfrankel commented 4 years ago

Sorry, could you please tell how is that related to Hazelcast?

bakedzebra commented 4 years ago

I'm just trying to guess if it's related or not. I had some thoughts about the Hazelcast because I fixed a bug that was caused by non-serializable entity that has been set to a session in the JSP file as it's attribute. Then I've received a Hazelcast exception that was related to Spring's MapSession. My thougths - Hazelcast manages sessions and their attributes as well.

bakedzebra commented 4 years ago

Could I also ask a question: Is it possible to use hazelcast-tomcat-sessionmanager for the Embedded Tomcat and Hazelcast Instances that are launched with Spring Boot?

nfrankel commented 4 years ago

Hazelcast doesn't manage session per se, but copy session data from one Tomcat instance to another, if they belong to the same cluster.

To make sure this is Hazelcast-related, please use a single node. If the problem is still there, it's completely unrelated.

nfrankel commented 4 years ago

This class shows how to use embedded Tomcat with Hazelcast via Spring Boot:

https://github.com/hazelcast/microservices-performance/blob/master/src/main/java/com/hazelcast/imdg/microservices/HazelcastDemo.java

bakedzebra commented 4 years ago

Thanks! I think I`ll close the issue.