How do I pass the session from context A to context B within Tomcat 05

5

I try two applications made in Java using Tomcat 6 and are in different contexts strong> but one interacts with the other because they are integrated, I need one to pass their session to the other context, or that contextA can set values in context B.

Ex:

ContextA. sessao.setAttribute("user", u);

ContextB. User u = (User)sessao.getAttribute("user");

    
asked by anonymous 05.01.2015 / 17:10

2 answers

4

This is a somewhat lengthy topic, but basically you need to configure session replication as described in Tomcat documentation .

The most basic step, according to the documentation, is to add the configuration below in server.xml , inside the <Engine> or <Host> tag:

<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>

However, the above configuration replicates the values for all Tomcat cluster nodes.

For a finer adjustment it is important to read the documentation in detail.

    
05.01.2015 / 17:20
0

I would honestly go for a more programmatic approach, because clustering can influence a lot of things down.

Use the approach of generating a token and save it to the bank. This way both projects would access the Token and see if it is still valid.

    
05.01.2015 / 23:44