-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I would like to know the best way to get an attribute of one session from another. We are working with different projects (.war) and every project has his own session. I want to set an attribute that represents the style of the first .war and then get that attribute from another session created by a second .war.
Which is the best way to do this? Can the second session get the attribute from the first one? There is other variable that the two sessions share? We use Tomcat.
Thank you,
Javier
There are definitely ways to share data between war files... however the servlet specification doesn't provide such. Since ZK is built on top of the servlet spec there isn't a mechanism within ZK either.
Instead you'll have to integrate solution outside the war files (e.g. JNDI, redis, ehcache) or a DB to share data between war files.
If the information isn't sensitive you might as well just set a cookie at root path '/' and read the cookie value from both web applications.
No need to change the session cookie configuration. Instead you add and get your own cookie using HttpServletResponse#addCookie(cookie) & HttpServletRequest#getCookies()
From inside your ZK applications you can get the request and response objects via:
HttpServletRequest request = (HttpServletRequest)Executions.getCurrent().getNativeRequest();
HttpServletResponse response = (HttpServletResponse)Executions.getCurrent().getNativeResponse();
Asked: 2020-12-01 01:20:37 +0800
Seen: 13 times
Last updated: Dec 03 '20