Hi omar thanks for the reply, I havent got your point. Please see the code which i have written
In action class am setting 24 which i need to show in same jsp
Struts.xml
-------------------
<action name="doLogin" class="com.wham.action.LoginAction">
<result name="success">1.jsp</result>
</action>
1.JSP
-------------
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>Login Success</title>
</head>
<body>
<s:form action="doLogin" method="POST" theme="simple">
Hello
<s:textfield name="customerName" id="customerName" theme="simple" />
<s:textfield name="myId" id="myId" theme="simple" />
<input type="submit" value="Save" class="button" />
</s:form>
</body>
</html>
Action
-----------
public class LoginAction extends ActionSupport implements org.apache.struts2.util.ServletContextAware,
ServletRequestAware,ServletResponseAware
{
ServletContext servletContext;
public
String execute() throws Exception
{
ServiceUtil.setServletContext(servletContext);
ApplicationContext ctx = ServiceUtil.getApplicationContext();
PlannedTaskService plannedService = (PlannedTaskService)ctx.getBean("plannedService");
if(getCustomerName.equals("Kartik")))
{
setMyId("24");
}
return SUCCESS;
}
private String customerName = null;
private String myId = null;
private HttpServletRequest request;
private HttpServletResponse response;
/**
* @return the customerName
*/
public String getCustomerName() {
return customerName;
}
/**
* @param customerName the customerName to set
*/
public void setCustomerName(String customerName) {
this.customerName = customerName;
}
public String getMyId() {
return myId;
}
public void setMyId(String myId) {
this.myId = myId;
}
/* (non-Javadoc)
* @see org.apache.struts2.util.ServletContextAware#setServletContext(javax.servlet.ServletContext)
*/
public void setServletContext(ServletContext servletContext) {
this.servletContext = servletContext;
}
/**
* @param request the request to set
*/
public void setServletRequest(HttpServletRequest request){
this.request = request;
}
/**
* @return the request
*/
public HttpServletRequest getServletRequest(){
return request;
}
/**
* @param response the response to set
*/
public void setServletResponse(HttpServletResponse response){
this.response = response;
}
/**
* @return the response
*/
public HttpServletResponse getServletResponse(){
return response;
}
}