How to retrieve a session Bean in the Context in a class with the Context reference

Discussion in 'Java' started by asd, Nov 9, 2006.

  1. asd

    asd Guest

    Hello this is my problem
    in my servlet I set a new session attribute
    request.getSession().setAttribute("AAA", new Aaa() );

    now I've a Xxx class that has access to the Application Context. In my
    Xxx class so I've a
    private ServletContext context;

    My Xxx class takes in input a String. this string is the sessionId.

    Now my question is: with a sessionId string and the attribute name
    ("AAA") can i retrieve in my Xxx class the bean stored by the
    request.getSession().setAttribute(..) in the appContext??

    thanks a lot
    martina
     
    asd, Nov 9, 2006
    #1
    1. Advertising

  2. If you're asking if you can get access to data stored in another users
    session, the answer is no.

    The Session is mapped to a single user, and a single user only.

    The ServletContext is global, and can be accessed by any user accessing
    your web appliation.

    Cheers!

    -Cameron McKenzie www.pulpjava.com

    Free SCJA Certification Questions: www.scja.com
    Free J2EE and WebSphere Tutorials: www.mcnz.com
    Free Mock WebSphere Certification Exams: www.examscam.com




    asd wrote:
    > Hello this is my problem
    > in my servlet I set a new session attribute
    > request.getSession().setAttribute("AAA", new Aaa() );
    >
    > now I've a Xxx class that has access to the Application Context. In my
    > Xxx class so I've a
    > private ServletContext context;
    >
    > My Xxx class takes in input a String. this string is the sessionId.
    >
    > Now my question is: with a sessionId string and the attribute name
    > ("AAA") can i retrieve in my Xxx class the bean stored by the
    > request.getSession().setAttribute(..) in the appContext??
    >
    > thanks a lot
    > martina
     
    www.pulpjava.com, Nov 9, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Benjamin Stewart

    To bean or not to bean...

    Benjamin Stewart, Jun 30, 2003, in forum: Java
    Replies:
    0
    Views:
    828
    Benjamin Stewart
    Jun 30, 2003
  2. David Thielen
    Replies:
    2
    Views:
    834
    Marek Lange
    Sep 12, 2003
  3. X3
    Replies:
    0
    Views:
    431
  4. Francesco
    Replies:
    3
    Views:
    500
  5. Replies:
    1
    Views:
    730
Loading...

Share This Page