JSTL-Struts problem

Hello everybody!!

I'm developing an application with struts and JSTL tags. Everything is OK but when I put a cancel button by using JSTL tags in my *.jsp (<html:cancel>Cancel</html:cancel>) and I clik it, all I get is the next:

[i]javax.servlet.ServletException

[i]org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:286)

org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)

org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)

javax.servlet.http.HttpServlet.service(HttpServlet.java:710)[/i]

javax.servlet.http.HttpServlet.service(HttpServlet.java:803)[/i]

org.apache.struts.action.InvalidCancelException

org.apache.struts.chain.commands.AbstractValidateActionForm.isCancelled(AbstractValidateActionForm.java:73)

org.apache.struts.chain.commands.AbstractValidateActionForm.execute(AbstractValidateActionForm.java:111)

org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)

org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)

org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)

org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)

org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)

org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)

org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)

javax.servlet.http.HttpServlet.service(HttpServlet.java:710)

javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

My JSP code:

<%@ taglib uri="/tags/struts-html" prefix="html"%>

<%@ taglib uri="/tags/struts-bean" prefix="bean"%>

<html>

<head>

<title>User Registration</title>

</head>

<body>

<h1>User Registration</h1>

<html:errors/>

<table>

<html:form action="userRegistration">

<tr>

<td>

<bean:message key="userRegistration.firstName" />*

</td>

<td>

<html:text property="firstName" />

</td>

</tr>

<tr>

<td>

<bean:message key="userRegistration.lastName" />*

</td>

<td>

<html:text property="lastName" />

</td>

</tr>

<tr>

<td>

<html:submit />

</td>

<td>

<html:cancel>Cancel</html:cancel>

</td>

</tr>

</html:form>

</table>

</body>

</html>

In my struts-config.xml:

<action path="/userRegistration"

type="strutsTutorial.UserRegistrationAction"

name="userRegistrationForm"

input="/userRegistration.jsp">

<forward name="success" path="/pages/Welcome.jsp" />

</action>

In my UserRegistrationAction.java:

publicclass UserRegistrationActionextends Action{

public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)throws Exception{

return mapping.findForward("success");

}

}

I really apreciate any help.

Thanks

[4147 byte] By [Javielloa] at [2007-11-27 9:52:22]
# 1
I think its the problem with the multiple submit buttons(submit and Cancel).Try removing <html:submit> for testing purpose and run it again.I think it will work..
vinayak_ra at 2007-7-13 0:21:26 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Thanks for the reply vinayak_r,

what you told me didn't fix it.

I've got the solution. It was a version problem:

I'm using struts 1.3.8, and as you can check in http://wiki.apache.org/struts/StrutsUpgradeNotes128to129#head-e417741603dac43bb4fbde589271c568309643e4

a new attribute must be used (cancellable="true") in the definition of the action in the struts-config.xml, as I indicate below:

<action path="/userRegistration"

type="strutsTutorial.UserRegistrationAction"

name="userRegistrationForm"

input="/userRegistration.jsp"

cancellable="true">

<forward name="success" path="/pages/Welcome.jsp" />

</action>

Thanks everybody for read. Thanks again vinayak_r.

Javielloa at 2007-7-13 0:21:26 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...