Struts 1.2: Why is not the reset, validate or even execute invoked?
Here is another one of those stupid mistakes that can keep you wondering what's going on;
As you probably know, Struts lets you override methods in the ActionForm class. It's quite common to override both the validate(), and reset() method.
It's however very important to notice that there exists two of each ;
public void reset(ActionMapping mapping,
javax.servlet.ServletRequest request)
public void reset(ActionMapping mapping,
javax.servlet.http.HttpServletRequest request)and
public ActionErrors validate(ActionMapping mapping,
javax.servlet.ServletRequest request)
public ActionErrors validate(ActionMapping mapping,
javax.servlet.http.HttpServletRequest request)If you override the wrong method (the ones with the ServletRequest signature, instead of HttpServletRequest), you'll soon notice that you code is not getting executed.
The JavaDoc claims for the generic methods "The default implementation attempts to forward to the HTTP version of this method." What "Attemts" means beats me. In the cases where I've made this mistake uptil now, that "attemt" has not succeeded.
Please note that this fact also applies to the Action class itself. There exists one execute() method for the Generic Servlet Class, and one for the HTTP Servlet.
I'm not sure why the design is like this; I havn't heard of anyone using Struts to SIP Servlets, or any other kinds of servlet other than HTTP.
If you googled for the problem, and found my page; Please let me know and add a comment ! :-)