Question

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)

.type("XYZ").build();

//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.HttpServletRequest)tools.getRequestor().getRequestorPage().getObject("pxHTTPServletRequest");

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.

Thanks

Gaurav

Comments

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.

https://community1.pega.com/community/product-support/question/how-can-we-read-cookies-container-managed-authentication

 

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

 

Regards

Gaurav