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

Asked

Viewed 458 times

5

Try two applications made in Java using Tomcat 6 and are in different contexts but one interacts with the other, by being integrated, I need one to be able to pass their session to the other context, or that contextA can set values in contextB.

Ex:

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

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

2 answers

4

This is a bit of a long topic, but basically you need to set up session replication as described in tomcat documentation.

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

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

However, the above setting replicates the values for all nodes of the cluster tomcats.

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

  • 1

    OK thank you very much, brilliant the idea of replicating, I’ll give a good read at Doc, I was already thinking of doing "Gambi" rsrs. Vlw.

0

Honestly I would go for a more programmatic approach, because the cluster configuration can influence much of the below.

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.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.