How to specify the functions of buttons in a .jsp

Im working on struts frame work and I want to add 3 buttons to a jsp as cancel,reset ans submit. I have done it like this. submit and reset buttons are working properly but when click the cancel button it gives an error like this.

Error

message: Request[/pages/jsp/smsserver/cancelData] does not contain handler parameter named rec

description: The request sent by the client was syntactically incorrect (Request[/pages/jsp/smsserver/cancelData] does not contain handler parameter named rec)

--

Submit button is for submit data and reset is for reseting.Also I just want to redirect to a .jsp when I clicked the cancel button. But when it clicked it given that error.Here I show my .jsp and action mapping in the strutsconfig.xml.

.xml code--

<action

name="showDetailsForm"

path="/pages/jsp/smsserver/submitData"

attribute="showDetailsForm"

scope="request"

type="com.ironech.myvoice.smsservice.struts.action.SendReportAction"

parameter="next"

>

<forward

name="updateSuccess"

path="system.configuration.updateSuccess"

/>

</action>

<action

path="/pages/jsp/smsserver/cancelData"

type="com.ironech.myvoice.smsservice.struts.action.SendReportAction"

parameter="rec"

scope="request"

>

<forward

name="sendSMSReportQueue"

path="system.configuration.sendSMSQueue"/>

</action>

.jsp- (this .jsp can be editted by the user and submit...)

<table width="75%" border="0" id="showdatatable">

<logic:iterate name="showDetailsForm" property="allProducts" id="SingleItem">

<form method="post" action="submitData.do?next=updateData">

<tr>

<td>Repeats</td>

<td>

<input type="text" name="srepeats" value="<bean:write name="SingleItem" property="repeats"/>" >

</td>

</tr>

<tr>

<td>Mobile No</td>

<td>

<input type="text" name="smobileNo" value="<bean:write name="SingleItem" property="mobileNo"/>">

</td>

</tr>

<tr>

<td width="41%" height="27">

<input name="Reset" type="reset" value="Reset">

</td>

<td width="59%">

<input type="submit" name="Submit2" value="submit">

</form>

</td>

<td width="41" height="27">

<form name="form1" action="cancelData.do?rec=sendReportQueue">

<INPUT name="cancel" type="submit" value="Cancel">

</form>

</td>

</tr>

</logic:iterate>

</table>

Please help me to figurout this matter. thanx....

[4106 byte] By [lmw_sa] at [2007-11-26 18:52:55]
# 1

Name attribute is missing in the second mapping.

Use html:cancel tag and use isCancelled() method in action class to redirect to your next/previous view.

In your case ..

Remove form tag for cancel button and use <html:cancel>

and in the action class for "submitData.do"

if(isCancelled(request)) {

return mapping.findforward("cancel_page");

}

add forward "cancel_page" in "submitData.do" mapping.

i hope this will solve your problem.

Vishwas_Prasannaa at 2007-7-9 6:26:57 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...