简体   繁体   中英

Session data between servlets within a cluster

So I'm not entirely certain how to word this question to ask it properly. I'll simply put down what I know of the situation, requirements, and ideas to paint the picture.

I have two servlets: one is a grails 2.1.1 servlet and another is a Spring Webflow servlet. I've been tasked with inserting an iframe of the grails servlet into a page on the Spring Webflow servlet. The issue I of course raised was one of session data. The servlets are deployed to tomcat on the same server yet there are 3 servers in the cluster (all 3 servers have both servlets on them). Sticky sessions are enabled. My question is this: will I even be able share session data between the two servlets? I'd imagine that an iframe would produce a new jsession id for the grails app. If I can share data between the two servlets, how would that be accomplished? Using the typical getAttribute/setAttribute functions?

Thanks for your thoughts!

In your setup, you can't share the data between different tomcat session directly. You have 2 options here:

  1. Use a medium between your tomcats for sharing and exchanging data, like database or some in-memory cache.

  2. Send all data you want within a http-request directly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM