• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Session value not displaying in jsp struts 2

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic