Struts questions

url


http://localhost:8080/webapp/dir/someaction.do?arg1=11&arg2=99

Hello world.jsp


<%@ include file="/includes/tld_includes.jsp" %>

<bean:define id="form-id" name="form-name" 
	type="com.com.YourFormClass" />
	
<html>
<body>
<h2>Hello world</h2>
<%
out.println("<p>begin");
out.println("<p>end");
%>
</body>
</html>

Declaring a bean


<form-bean 
	name="form-name" 
	type="com.com.YourFormClass">
</form-bean>

Modified action


<action path="/dir/someaction" 
		type="com.com.YourFormAction" 
		parameter="method" 
		name="form-name" 
		scope="request" 
		validate="false">
<forward name="showReport" 
		path="/satya-test/hello-world.jsp" redirect="false"></forward>
</action>

Form class


public class YourFormClass extends BaseActionForm
{
    private String arg1 = null;
    public YourFormClass(){  super(); }

    public void setDefaults(HttpServletRequest request) throws Exception
    {
        super.setDefaults(request);
    }
    
}

Action class


public class YourFormAction extends DispatchBaseAction
{
	public YourFormAction(){super();}

    protected void processParameters(HttpServletRequest request, YourFormClass form) throws Exception
    {
        String arg1 = request.getParameter("arg1");
        form.setArg1(arg1);
    }
    
	public ActionForward showReport(
		ActionMapping mapping,
		ActionForm actionForm,
		HttpServletRequest request,
		HttpServletResponse response)
		throws Exception
	{
		return mapping.findForward("showReport");
	}//end of method
}//end of class