• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Lost session value

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This question belongs in our Servlets forum. I will move it there for you.
 
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Today's lesson is that you can't wear a jetpack AND a cape. I should have read this tiny ad:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic