Question

3
Replies
297
Views
GauravS9130 Member since 2018 8 posts
Apple Inc
Posted: 1 year ago
Last activity: 1 year 7 months ago
Closed

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

Pega Platform Low-Code App Development Data Integration Java and Activities Data Integration
Moderation Team has archived post
Share this page LinkedIn