2

I have a project. In the first project I set the session

in my first project I put here as code

req.getSession().setAttribute("x", name);
return "ses";

In second project I put here

model.addAttribute("ses", req.getSession().getAttribute("x"));
return "oses";

but session is not appear.

How to make a session appear in different project with Spring framework?

jeha
  • 10,562
  • 5
  • 50
  • 69
user965347
  • 186
  • 2
  • 16

2 Answers2

1

You can't. (Well, perhaps you can setup some sort of session-replication, but you shouldn't do it. See related question)

You should use other forms of communication between your applications. The flow will be more complicated and will include exchange of tokens through (simple) web services, but it is better than relying on the server container, and on the fact that both applications will be run in the same container.

Community
  • 1
  • 1
Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
  • thanks for the answer, so this is complicated, so it must be use other form for communication. or, maybe i need to make my application mix in it, ok i see thanks for answer Bozho :thumbup: – user965347 Oct 30 '11 at 08:41
  • note that JNDI is not per-session, it is global. So you'd have to somehow identify users based on some session id – Bozho Oct 30 '11 at 09:10
0

It'd be helpful to describe what you're actually trying to accomplish; as Bozho says you can't really share session objects between apps.

You could, however, use JMS (or any other intra-app comms) to send data from one app to another. You'll still need the capability to decide what to do with that data once you have it in the receiving app: how do I associate it with a given user, how do I get it into that user's session, and so on.

User information can be passed in the message, but there has to be some commonality between the two systems, some agreed-upon key, that can be used to figure out who the info belongs to.

Once you have that, the rest is mechanics; there are interesting games to be played, and it's easy to mess it up :)

Dave Newton
  • 158,873
  • 26
  • 254
  • 302