Session attribute returns null when returning from view

Loupblanc

New Member
I'm currently trying to save search criteria attributes to the session between two pages: search page and edit page. The goal is to save the three variables: sYear, submission, collectionPeriod. I'm adding these to the session here below in the Search screen controller:\[code\]request.getSession().setAttribute("sYearSave", sYear);request.getSession().setAttribute("submissionSave", submission);request.getSession().setAttribute("collectionPeriodSave", collectionPeriod);\[/code\]In the edit screen controller, I set a Boolean\[code\]isFromEditScreen\[/code\] to \[code\]true.\[/code\] This is so I know that I'm coming from the edit screen. I do print out the variables and I do get the values correctly here in the edit controller screen.\[code\]request.getSession().setAttribute("isFromEditScreen", new Boolean(true)); sYearSave = (String)request.getSession().getAttribute("sYearSave"); collectionPeriodSave = (String)request.getSession().getAttribute("collectionPeriodSave"); submissionSave = (String)request.getSession().getAttribute("submissionSave");\[/code\]But the problem is when I use a back button to go back to the Search screen, the \[code\]sYearSave, collectionPeriodSave, and submissionSave\[/code\] values return \[code\]NULL.\[/code\] For some reason, the \[code\]isFromEditScreen\[/code\] boolean works just fine and returns \[code\]true.\[/code\] It actually enters the statement but what search criteria return \[code\]null.\[/code\] The Search controller code is below:\[code\]if (isFromEditScreen != null && isFromEditScreen == true) { System.out.println("Inside isFromEditScreen ==== true"); sYear = (String)request.getSession().getAttribute("sYearSave"); collectionPeriod = (String)request.getSession().getAttribute("collectionPeriodSave"); submission = (String)request.getSession().getAttribute("submissionSave"); sYearSave = (String)request.getSession().getAttribute("sYearSave"); collectionPeriodSave = (String)request.getSession().getAttribute("collectionPeriodSave"); submissionSave = (String)request.getSession().getAttribute("submissionSave"); System.out.println("sYearSave ==== " + sYearSave); System.out.println("submissionSave ==== " + submissionSave); System.out.println("collectionPeriodSave ==== " + collectionPeriodSave); System.out.println("isFromEditScreen set in else ==== " + isFromEditScreen); }\[/code\]Any help would be greatly appreciated!
 
Back
Top