| Author |
Exception in Running Struts in Tomcat
|
Mary Gates
Greenhorn
Joined: Mar 20, 2005
Posts: 7
|
|
I had the following error when I try to run struts in Tomcat: javax.servlet.ServletException: Cannot find ActionMappings or ActionFormBeans collection Here is my index.jsp <%@ page language="java" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %> <html> <head><title>Submit example</title></head> <body> <h3>Example Submit Page</h3> <html:errors/> <html:form action="submit.do"> Last Name: <html:text property="lastName"/><br> Address: <html:textarea property="address"/><br> Sex: <html:radio property="sex" value="M"/>Male <html:radio property="sex" value="F"/>Female<br> Married: <html:checkbox property="married"/><br> Age: <html:select property="age"> <html ption value="a">0-19</html ption> <html ption value="b">20-49</html ption> <html ption value="c">50-</html ption> </html:select><br> <html:submit/> </html:form> </body> </html> Here is my web.xml <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd"> <web-app> <servlet> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class&g t; <init-param> <param-name>application</param-name> <param-value>ApplicationResources</param-value> </init-param> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml</param-value> </init-param> <init-param> <param-name>debug</param-name> <param-value>2</param-value> </init-param> <init-param> <param-name>detail</param-name> <param-value>2</param-value> </init-param> <init-param> <param-name>validate</param-name> <param-value>true</param-value> </init-param> <load-on-startup>0</load-on-startup> </servlet> <!-- Standard Action Servlet Mapping --> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <!-- Struts Tag Library Descriptors --> <taglib> <taglib-uri>/tags/struts-bean</taglib-uri> <taglib-location>/WEB-INF/struts-bean.tld</taglib-location> </taglib> <taglib> <taglib-uri>/tags/struts-html</taglib-uri> <taglib-location>/WEB-INF/struts-html.tld</taglib-location> </taglib> <taglib> <taglib-uri>/tags/struts-logic</taglib-uri> <taglib-location>/WEB-INF/struts-logic.tld</taglib-location> </taglib> </web-app> Here is my struts-config.xml <?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd"> <struts-config> <!-- ================================================ Form Bean Definitions --> <form-beans> <!-- sample form bean descriptor for an ActionForm <form-bean name="submitForm" type="hansen.playground.SubmitForm"/> end sample --> </form-beans> <!-- =========================================== Action Mapping Definitions --> <action-mappings> <action-mappings> <action path="/submit" type="hansen.playground.SubmitAction" name="submitForm" input="/submit.jsp" scope="request"> <forward name="success" path="/submit.jsp"/> <forward name="failure" path="/submit.jsp"/> </action> </action-mappings> </struts-config> Here is my two source of classes both in web-inf/classes/hansen/playground/ SubmitForm.java package hansen.playground; import javax.servlet.http.HttpServletRequest; import org.apache.struts.action.*; public final class SubmitForm extends ActionForm { /* Last Name */ private String lastName = "Hansen"; // default value public String getLastName() { return (this.lastName); } public void setLastName(String lastName) { this.lastName = lastName; } /* Address */ private String address = null; public String getAddress() { return (this.address); } public void setAddress(String address) { this.address = address; } /* Sex */ private String sex = null; public String getSex() { return (this.sex); } public void setSex(String sex) { this.sex = sex; } /* Married status */ private String married = null; public String getMarried() { return (this.married); } public void setMarried(String married) { this.married = married; } /* Age */ private String age = null; public String getAge() { return (this.age); } public void setAge(String age) { this.age = age; } } SubmitAction.java package hansen.playground; import javax.servlet.http.*; import org.apache.struts.action.*; public final class SubmitAction extends Action { public ActionForward perform(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { SubmitForm f = (SubmitForm) form; // get the form bean // and take the last name value String lastName = f.getLastName(); // Translate the name to upper case //and save it in the request object request.setAttribute("lastName", lastName.toUpperCase()); // Forward control to the specified success target return (mapping.findForward("success")); } } Please help with the exception.. Thanks
|
 |
Harish Kashyap
Ranch Hand
Joined: Jun 14, 2000
Posts: 118
|
|
The error is here. You have commented out the <form-bean> tag <form-beans> <!-- sample form bean descriptor for an ActionForm <form-bean name="submitForm" type="hansen.playground.SubmitForm"/> end sample --> </form-beans>
|
 |
Mary Gates
Greenhorn
Joined: Mar 20, 2005
Posts: 7
|
|
Thank you so much.... You get really sharp eyes... Regards
|
 |
 |
|
|
subject: Exception in Running Struts in Tomcat
|
|
|