I have a simple application in struts 2 that allows the user to input the name and submitted.In the server side in struts 2 action class a new session is created and stored the value of username in the session.In the user.jsp I tried to display the value stored in session but it is not displaying anything.
The code for Index.jsp is given below
<body>
<form action="welcomeUser.action">
<input type="text" name="user">
<input type="submit" value="Submit">
</form>
</body>
The code in struts.xml is given below
<action name="welcomeUser" class="hart.test.Welcome">
<result name="success">user.jsp </result>
</action>
The code in hart.test.Welcome is given below
public class Welcome extends ActionSupport
{
private String user;
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
public String execute()
{
HttpServletRequest request = ServletActionContext.getRequest();
HttpSession session=request.getSession();
//Checking session is new and creating a session
if (session.isNew() == false) {
session.invalidate();
session = request.getSession(true);
}
session.setAttribute("user1", user);
return SUCCESS;
}
}
The code in User.jsp is given below
<body>
Welcomeee <s:property value="%{#session.user1}"/>
</body>
The problem is that it is displaying only 'Welcomeee'.Can anyone please tell the reason for it