user624558
user624558

Reputation: 549

How to set request parameter to be avaiable within a session if the session is reset for some other reason

String reqParam=request.getParameter("param");

    if(reqParam!=null){
          HttpSession session=request.getSession(false);
          if(session!=null){
            session.setAttribute("reqParamInSession", reqParam);
          }
    }

I use the code above to set a request parameter value into a session when a doFilter method is called. But when the user navigates to a different experience(assume a user that manages three different branches of a shop will have separate experience for each branch) the session is cleared other than the user profile. I don't manage the module that resets the session when the user experience is changed. But I still need the parameter I set in session even if the user has changed experience.

Is there a way to associate the parameter to every request sent regrdless of the session being changed? Or any other way to handle this?

Upvotes: 1

Views: 863

Answers (1)

jazzdup
jazzdup

Reputation: 89

Dont' use application scope as if the session is closed for any reason the params won't be cleared. Use cookies if you can.

Upvotes: 1

Related Questions