public static Object getSessionValue(HttpServletRequest request, String key) {

        HttpSession session = request.getSession(true);
        return session.getAttribute(key);
    }
public static Object getSessionValue ( HttpServletRequest request , String key ) { HttpSession session = request . getSession ( true ) ; return session . getAttribute ( key ) ; }
Reads an object from the session of the given HTTP request.<p>

A session will be initialized if the request does not currently have a session.
As a result, the request will always have a session after this method has been called.<p>

Will return <code>null</code> if no corresponding object is found in the session.<p>

@param request the request to get the session from
@param key the key of the object to read from the session
@return the object received form the session, or <code>null</code>