hello people,
i like to knoe how do you pass paramter from .java to struts-config.xml and then forward it .jsp(view).and how to fetch the parameter in the View.
.java file -->
package app;
import org.apache.struts.action.*;
import javax.servlet.http.*;
import java.io.*;
public class addaction extends Action
{
public ActionForward perform(ActionMapping mapping,ActionForm form,HttpServletRequest req,HttpServletResponse res)
{
addform rf=(addform)form;
String noa=rf.getNoa();
String nob=rf.getNob();
String noc=String.valueOf(Integer.parseInt(noa)+Integer.parseInt(nob));
req.setAttribute("&noc",noc);// ???IS IT OK
return mapping.findForward( "success" );
}
}
struts-config.xml-->
<struts-config>
<form-beans>
<form-bean name="addjorm" type="app.addform"/>
</form-beans>
<action-mappings>
<action path="/add" type="app.addaction" name="addjorm">
<forward name="success" path="/success.jsp"/>
</action>
</action-mappings>
</struts-config>
.jsp(view)--->
<%@page language="java"%>
<html>
<title>
Success
</title>
<body>
<%!String s;%>
<% s=(String)request.getAttribute("&noc");// i did like this but it always print null
%>
<form>
The value =<input type=text name="t" value=<%=s%>/>!!!<p><a href="add.jsp"> try someother???</a></p>
</form>
</body>
</html>
Any ideas ???
tx
TUHIN