Class SessionData


  • public class SessionData
    extends java.lang.Object
    To access session data without having access to HttpServletRequest or HttpSession.

    It has to be used from inside an OpenXava request, though you can use it in any part of your application: JSPs, actions, calculators, validators, entities, etc.
    An advantage of using this class over direct request.getSession() is that it abstracts your code from web technology, so that code could work in other contexts, as Swing for example.

    Since:
    5.7
    Author:
    Javier Paniza
    • Constructor Summary

      Constructors 
      Constructor Description
      SessionData()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void clean()
      If you use SessionData in your own servlet call to this method at end.
      static java.lang.Object get​(java.lang.String key)
      If not session available returns null.
      static void put​(java.lang.String key, java.lang.Object value)  
      static void remove​(java.lang.String key)  
      static void setCurrent​(javax.servlet.http.HttpServletRequest request)
      To use SessionData in your own servlet first call to this method.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SessionData

        public SessionData()
    • Method Detail

      • setCurrent

        public static void setCurrent​(javax.servlet.http.HttpServletRequest request)
        To use SessionData in your own servlet first call to this method.
      • clean

        public static void clean()
        If you use SessionData in your own servlet call to this method at end.
      • get

        public static java.lang.Object get​(java.lang.String key)
        If not session available returns null.
      • put

        public static void put​(java.lang.String key,
                               java.lang.Object value)
        Throws:
        java.lang.IllegalStateException - If not session available.
      • remove

        public static void remove​(java.lang.String key)
        Throws:
        java.lang.IllegalStateException - If not session available.