简体   繁体   English

集群中Servlet之间的会话数据

[英]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. 我有两个servlet:一个是grails 2.1.1 servlet,另一个是Spring Webflow servlet。 I've been tasked with inserting an iframe of the grails servlet into a page on the Spring Webflow servlet. 我的任务是将grails servlet的iframe插入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). 这些Servlet部署到同一服务器上的tomcat,但是集群中有3台服务器(所有3台服务器上都装有servlet)。 Sticky sessions are enabled. 粘性会话已启用。 My question is this: will I even be able share session data between the two servlets? 我的问题是:我什至可以在两个servlet之间共享会话数据吗? I'd imagine that an iframe would produce a new jsession id for the grails app. 我以为iframe将为grails应用程序生成一个新的jsession id。 If I can share data between the two servlets, how would that be accomplished? 如果我可以在两个servlet之间共享数据,那将如何实现? Using the typical getAttribute/setAttribute functions? 使用典型的getAttribute / setAttribute函数?

Thanks for your thoughts! 感谢您的想法!

In your setup, you can't share the data between different tomcat session directly. 在您的设置中,您不能直接在不同的tomcat会话之间共享数据。 You have 2 options here: 您在这里有2个选项:

  1. Use a medium between your tomcats for sharing and exchanging data, like database or some in-memory cache. 在您的tomcat之间使用一种介质来共享和交换数据,例如数据库或某些内存中的缓存。

  2. Send all data you want within a http-request directly. 直接在http请求中发送您想要的所有数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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