How to getSession from HttpServletRequest

Hi Team,

We have written a filter where we are saving some details in HTTPSession like below.

// Create a new session

HttpSession session = httpServletRequest.getSession(true);

// Create the session bean

SessionBean sessionBean = SessionBean.builder().id(1263333)


//Set the session bean with required details into session

session.setAttribute(SESSION_BEAN_NAME, sessionBean);

We are trying to read it in our authentication activity inside java step like below.

javax.servlet.http.HttpServletRequest request =

javax.servlet.http.HttpSession sessionDetails = request.getSession(); // Always returning NULL ??

But getSession is always returning null inside activity. We are able to read other HttpServletRequest methods like getCookies.

Please provide input in case you also have encountered similar situation.




Keep up to date on this post and subscribe to comments

March 22, 2019 - 6:35pm

 Hi Team,

 We are able to read cookie as getCookies method works perfectly fine. But we are trying to get a Bean which was setup in Session. And as soon as we try to do getSession it returns as NULL.

In the below post Chris also confirmed that getSession method is not available.


Is there any other way , We can read beans setup by Filter?