• Post Reply Bookmark Topic Watch Topic
  • New Topic

Lost session value  RSS feed

 
age spets
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

This question might be very easy... I have 2 different applications where the first one links to the other. I want to set the name om the user in the session and then use this in the next. What I am doing is:
1.
String name="STRHEI";//request.getAttribute("name").toString();
session.setAttribute("bruker",name);
<a href=http://localhost:9080/XXX/XXX.jsp>Tips</a>
2.
session = request.getSession(true);
String profils=(String)session.getAttribute("bruker");
System.out.println("jsp="+profils);

Prints out null.... Why isn't the value in the session? Does the href starts a new session? WHat is the workaround?

Age
 
Scheepers de Bruin
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Each connection to an application has it's own session. These sessions are not shared, so if you set a session attribute in a session in one application it will not show up in another session in another application.

I'm not entirely sure what you are trying to do?
[ September 08, 2005: Message edited by: Scheepers de Bruin ]
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question belongs in our Servlets forum. I will move it there for you.
 
Paul Bourdeaux
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have 2 different applications

that is the problem, you have two different applications. As mentioned in an earlier post, sessions cannot be shared between applications.

One possible workaround would be to put the information into request scope instead. Then the information is sent along with the request, instead of being stored in the session on the server side.
 
Mahesh Rana
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or, If you dont want to expose the session information by putting it in request, here is slight variation to the work around:

You can always serialize the session (to file, db, etc), and at every entry point in both of your applications, read the serialized object first to create fresh session.

In the request, you can pass ID of Serialized object (File name or db row_id or ..) so both the apps know how to create session from serialized data.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!