i show you the code for your problem and you will get the idea...
Action:-
package com.stikiflem;
import java.util.Map;
import org.apache.struts2.interceptor.SessionAware;
import com.opensymphony.xwork2.ActionSupport;
public class ForwordAction extends ActionSupport implements SessionAware
{
private
String userName;
private String password;
private Map session;
public String getUserName()
{
return userName;
}
public void setUserName(String userName)
{
this.userName = userName;
}
public String getPassword()
{
return password;
}
public void setPassword(String password)
{
this.password = password;
}
public String forword()
{
session.put("username", getUserName());
// setUserName(userName);
return "success";
}
public String execute()
{
userName=(String)session.get("username");
setUserName(userName);
setPassword(password);
return SUCCESS;
}
public Map getSession()
{
return session;
}
public void setSession(Map session)
{
this.session = session;
}
}
1st jsp page
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="ForwordAction.action">
<input type="text" name="userName"/>
<input type="submit" value="Next" id="submit"><br>
</form>
</body>
</html>
2nd jps page
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form action="NextAction.action">
<input type="text" name="password"/>
<input type="submit" value="submit" id="submit"><br>
<s:property value="userName"/>
</form>
</body>
</html>
3rd jsp page
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<s:property value="userName"/>
<s:property value="password"/>
</form>
</body>
</html>
Struts.xml
<action name="ForwordAction" class="com.stikiflem.ForwordAction" method="forword">
<result name="success">Next.jsp</result>
</action>
<action name="NextAction" class="com.stikiflem.ForwordAction">
<result name="success">success.jsp</result>
</action>