Discussions

EJB programming & troubleshooting: session management

  1. session management (4 messages)

    Dear JavaPros,

    I have an issue with using the ServletContext class for passing objects between applications. The application that we are trying to develop is a conglomerate of different web apps deployed to jakarta-tomcat-4.1.12 servlet engine. Each web app has its own controller servlet and is a full fledged application that can function independently. What I am trying to do is to login to one app and then try to access other apps from there on without any additional authentication to use the other web apps.

    Let us call the apps webappA and webappB
    When I log in to webappA, I need to create
    an object of a UserProfile class which I wrote
    as a utility class which stores a lot of the user
    information retrieved from a backend ADABAS file.
    I need to pass this UserProfile to other apps which
    the user would like to navigate to.

    In other words, I need to do something like the code below

    webappA/ServletA

    ServletContext webappAContext = getServletContext();
    UserProfile userProfile = UserProfile.retrieve("userId");
    webappAContext.setAttribute("someId", userProfile);

    In webappB/ServletB

    ServletContext webappBContext = getServletContext();
    ServletContext webappAContext = webappBContext.getContext("/webappA");
    UserProfile userProfile = (UserProfile) webappAContext.getAtribute("someId");

    The question is the ServletB must know a unique identifier ("someId") with which it can
    retrieve the UserProfile object. I am at a loss to figure out how this could
    be done.

    Any thoughts on this one?

    Thanks and Best Regards,

    Sunil

    Threaded Messages (4)

  2. session management[ Go to top ]

    pass the Id in the URL as a request parameter
  3. session management[ Go to top ]

    Any how you are accessing applications from same browser, When you are accessing first application put that 'some id' in session and later on when you are accessing second application you can get it back.
  4. session management[ Go to top ]

    Two diferent web application can share the same session???
    session == request.getSession(true) ????
  5. session management[ Go to top ]

    I have not tried this. But I feel that two different web applications use separate sessions and therefore may not work.