How can I set a session object which I can use then in any of my views by using ${variable} or ${requestScope.variable}
To be able to use sessions do I need to set <%@ page session="true" %> ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want to access a session variable in your view the easiest way to do it is :
See the Using Scope Objects for more info.
If you set
<%@ page session="true">then the JSP will merge the session scope and at the page scope into a single namespace. Then you can do:You can put something into the session in a mvc controller like this:
Finally, the @SessionAttribute is meant for a specifc use case, and doesn’t put variables into the session so that anyone can access them:
Here is how the spring folks describe the functionality of @SessionAttribute: