I have a webpage that contains a header and a main section. Both the header and the main section make the same call to one particular Java API running on my server. The first call should establish a session and set a flag in the session which prevents the second call from proceeding until the first call completes (e.g. its blocking).
What currently happens is the header usually makes the call first, establishes a session and sets the flag. Then, the main section makes the call; however, for some reason, it is establishing an entirely new session so it never sees the flag and both calls run consecutively. This consecutively running process causes a problem with the underlying database which is a separate issue.
So my question is, why are two separate sessions being established? Why isn't the second call recognizing the first session and using it?