Home > front end >  How to get Spring Boot session attributes several request layers down
How to get Spring Boot session attributes several request layers down

Time:05-30

Is there a way to get request.request.request.session.attributes as seen in the hierarchy in the image? I have tried the following:

enter image description here

Object value = request.getAttribute("Travis");

and

Object value2 = request.getSession().getAttribute("Travis");

However, both return null. I have confirmed the session Id is correct.

Is there a way to grab values from the request this deep down?

CodePudding user response:

I was able to get the data by using the HazelcastHttpSession. HazelcastHttpSession session.

Object value = session.getOriginalSession().getAttribute("Travis");

CodePudding user response:

You can access session directly with HttpSession:

import javax.servlet.http.HttpSession;

// for instance
@GetMapping("test")
public void test(HttpSession session) {
  session.getAttribute("Travis");
}
  • Related