I am learning struts. I did one sample struts program. i have one problem that nothing is happening in action class when i submit a page. i don't know what is happenging there. I have configured xml files correctly. The following files are being used: struts-config.xml ****************** <form-beans> <form-bean name="LoginForm" type="com.atroad.form.LoginForm"/> </form-beans> <action-mappings> <action path="/LoginAction" name="LoginForm" type="com.atroad.action.LoginAction" scope="request"> <forward name="success" path="com/atroad/ui/success.jsp"/> </action> </action-mappings> web.xml ********** <servlet> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> Action class ***************
Your struts-config.xml , web.xml , Action and ActionForm code seems to be ok.. The only difference which i am seeing here is in the signature of the ActionForward , You have written like this :
public ActionForward execute(HttpServletRequest request,HttpServletResponse response,ActionMapping mapping,ActionForm form)throws Exception ---> The use of direct Exception class should be avoided.
while normally which i have seen is like this :
public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)throws IOException,ServletException. I dont know if changing the signature would work , but you may try. Anywayz , Lets wait for the experts opinion, Merrill , please come at the rescue. :-)
Can you let us know the exact error which you are coming across , perhaps the Stack trace would suffice..
You say "Nothing is Happening there", Where are you submitting form from ? which is the page which actually is sending control to /LoginAction ? Can you post that JSP as well.. Also in your web.xml i was not able to see any TLD declaration of the struts html,bean tlds. Have you also made sure that struts.jar is in WEB-INF/lib directory ?
Please answer this questions in order to help you more precisely.
Yogendra N Joshi. [ October 31, 2006: Message edited by: Yogendra Joshi ]
Meri Zindagi Hain Tab Tak.. Jab Tak Tera Sahara.... Har Taraf Tu Hi Tu Hain SAI Tera Hi Hain Nazara.....
i have verified that struts.jar is in lib directory and stored tld file in WEB-INF directory.
The control goes to action class and there i have given a print statement. That is not displayed in console of server. There is no error in action class. I can see the the text like :http://localost:8080/LoginAction.do" once i submit the form. That is what i was wondering that server doesn't show any error.
Hi arulraj, <forward name="success" path="com/atroad/ui/success.jsp"/> </action> From the structural heirchary,I think that your JSP is in the WEB-INF. And that is why it is not being displayed. If at all, remove it from there and then it would work fine. Secondly, if the SOP is not printed, then it doesnt go to your action class. Please put some SOP in the ActionForm and then check. Regards, Roshani [ October 31, 2006: Message edited by: RoshaniG Gopal ]
Joined: Mar 02, 2005
The control goes to actionForm, but not to Action class.