Hello,
 
I am just getting underway with struts and found an example here:  
http://javaboutique.internet.com/tutorials/Struts/
 
I have completely followed the directions and I can get the initial form to 
display the data that comes from the ActionForm bean. "Hansen".
 
But after I hit the submit, I just get a blank page. I have double, triple 
checked all config settings, but cannot figure out where the problem is. The 
Tomcat console does not show any error, and there appears to be no error 
anywhere. Problem is, it just does not display the submit.jsp page back with 
updated results.
 
If anyone has ideas, please let me know. Especially if there is a way to find 
any type of log from Tomcat. I cannot find any type of output from the app.
 
Thanks,
Scott
 
 
Here are my files:
my webapp is called "firststrut"
The classes are in package "com"
The file structure is correct
 
 
 
/WEB-INF/classes/com
package com;
 
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) {
 
 
    System.out.println("SubmitAction extends Action class ######");
 
    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"));
  }
 
}
 
/WEB-INF/classes/com
package com;
 
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.*;
 
public final class SubmitForm extends ActionForm {
 
  /* Last Name */
  private String lastName = "AMF"; // default value
  public String getLastName() {
      System.out.println("Getting last name");
    return (this.lastName);
  }
  public void setLastName(String lastName) {
    this.lastName = lastName;
  }
 
  /* Address */
  private String address = "1313 Mockingbird Lane";
  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;
  }
 
}


 
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>
 
  <!-- Standard Action Servlet Configuration (with debugging) -->
  <servlet>
    <servlet-name>action</servlet-name>
    <servlet-class>
        org.apache.struts.action.ActionServlet
 </servlet-class>
    <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>2</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>/WEB-INF/struts-bean.tld</taglib-uri>
    <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
  </taglib>
 
  <taglib>
    <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
    <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
  </taglib>
 
  <taglib>
    <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
    <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
  </taglib>
 
</web-app>

 
struts-config.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
 
<!DOCTYPE struts-config PUBLIC
 "-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
 " http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd";>
 
<struts-config>
 
  <!-- ========== Form Bean Definitions ================= -->
  <form-beans>
 
    <form-bean      name="submitForm"
                    type="com.SubmitForm"/>
 
  </form-beans>
 
  <!-- ========== Action Mapping Definitions ============ -->
  <action-mappings>
 
    <action   path="/submit"
              type="com.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>

 
 

Scott K Purcell | Developer | VERTIS | 
555 Washington Ave. 4th Floor | St. Louis, MO 63101 | 
314.588.0720 Ext:1320 | [EMAIL PROTECTED] | http://www.vertisinc.com 
<http://www.vertisinc.com/>  

Vertis is the premier provider of targeted advertising, media, and 
marketing services that drive consumers to marketers more effectively. 
                                                 

 

Reply via email to