0

i'm new to gwt.

I am trying to set and get the http sessionattributes, but not able to retrive

i've three pages in my application. page1 is for login. when the user enters the username and password, i'll get session using HttpSession session = this.getThreadLocalRequest().getSession() and set them session attributes in the servlet. meanwhile i'll authenticate the user to the page2. In page2 i need the same username and password to authenticate the user to page3, where when i get session using HttpSession session = this.getThreadLocalRequest().getSession(), i get a new session and when i call session.getAttributes("username") and session.getAttributes("password"), i get only null values.

Please let me know if the HttpSession session has to be made as an instance variable of the servlet or anything i'm missing

Rajesh
  • 382
  • 3
  • 14

2 Answers2

0

The login page 1 (I do not understand why you have a page 2) need to create a cookie set with your session ID if successful authentication, then redirect to next page and validate this next page request on the server with XSRF token containing the session ID -- see this SO for recipe.

Community
  • 1
  • 1
Patrick
  • 1,561
  • 2
  • 11
  • 22
0

Thank you very much for the link. it was useful.

But my issue is resolved now. making the getsession parameter "false" did the trick :) previously i didn't have any parameter and hence the default parameter "true" was assigned.

Answer to my question:

// dont create a new one -> false

HttpSession session = request.getSession(false);

// create new session

HttpSession session = request.getSession(true);

Rajesh
  • 382
  • 3
  • 14