Discussions

General J2EE: Session Attribute access notification

  1. Session Attribute access notification (6 messages)

    I was wondering is there anyways to get notificatons to the object when it is accessed from session. By that i mean in HttpSession getAttribute(String x) method is there a way i could hook up to this anytime its called and do some custom stuff. Does it fire any events or notifications or is there an interface that i can implement to do this.

    Threaded Messages (6)

  2. Sounds like a job for...[ Go to top ]

    ...HttpSessionAttributeListener!!!!

    Information on this can be found at eiter of these URLs...

    http://java.sun.com/developer/EJTechTips/2003/tt0626.html
    http://edocs.bea.com/wls/docs70/webapp/app_events.html#177041

    Enjoy!
  3. Doesnt work[ Go to top ]

    HttpSessionAttributeListener only lets you know if An attribute
    1. has been added
    2. removed
    3. replaced

    it doesnt let you know if an attribute is being accessed from session with getAttribute(String) and this is what i want to know.
  4. I thnk u can use observer. have a look at it.
  5. Could u explain how observer pattern could be use for this without implementing your own HttpSession. All i would really need to do is to somehow put some code in the getAttribute method to receive notifications but this would require implementing HttpSession which is not a very good idea since this is allready provided by the app server.
  6. J2EE experts i really need advice on this one thnx.
  7. How about writing your HttpSession.getAttribute()?
    Extending HttpSession?