session.getAttribute and session.setAttribute in Spring MVC

session.getAttribute and session.setAttribute in Spring MVC
Here is an example of how to use session.setAttribute and session.getAttribute, the same way we use in Servlets.  (for Spring mvc simple form handling example-click here and for Multiple submit buttons in spring mvc form – click here).

In this example we are going to see how to use “session.setAttribute” and “session.getAttribute”. We are going to get username in page1.jsp and then control passes to page2.jsp and we are going to display the username in page3.jsp using session attributes.

Structure:
Structure

employee.java

page1.jsp

page2.jsp

page3.jsp

econtroller.java

applicationContext.xml

dispatcher-servlet.xml

Output

op1

op2

op3

 

 

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *