Discussions

EJB design: How to read session values across application

  1. How to read session values across application (5 messages)

    I created two application App1 and App2, under App1 I created a servlet servlet1 created a session and put the value "renewal" like below

    String renewal="Y";
    HttpSession session = request.getSession(true);
    session.setAttribute("renewal",renewal);
    and created servelt named servlet2 in App2 application and tried to read the

    renewal session value like below
    HttpSession session = request.getSession(true);
    System.err.println("Renewal session value
    "+(String)session.getAttribute("renewal"));
    I got null value.
    At the same time when i put both servlets in same application I got the value
    back.
    Two application are running under same OC4J
    Thanks
    kiru
  2. Hi Kiru,

    By default http sessions are not shared across applications. With Coherence*Web you can easily shares session across applications as well as in a cluster.

    Later,
    Rob Misek
    Tangosol, Inc.
    Coherence: It just works.
  3. Session objects are context specific. Meaning they are not shared across multiple application contexts.In some web containers(like tomcat) they allow something like "crosscontext" which allows the context to be shared across applications. you might wanna look into your webcontainers documentation if it allows something like that.

    <Context path="/examples" docBase="webapps/examples" crossContext="false" debug="0" reloadable="true" > </Context>


    ~Adi
  4. Probably u might want to get the context of App1 and then get the session for that app and look into it. But is it possible ?
  5. Using the database[ Go to top ]

    Have App1 insert a record in a table that will be read by App1.
  6. correction[ Go to top ]

    I meant "that will be read by App2"