You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Robbie Anonymous <ro...@lycos.com> on 2005/05/29 12:52:23 UTC

RE: Action class defined in action-mappings not being executed - without 2mb webapp source

I fixed the dtd to be struts 1.2 as thats the version of my struts.jar (Struts 1.2.4).
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
              "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
              "http://struts.apache.org/dtds/struts-config_1_2.dtd">
still doesnt work.

I'm using an execute() method and the code (along with method signature) is below

/*
 * AddContactUs.java
 *
 * Created on May 26, 2005, 10:24 AM
 */

package com.devfirm.actions;

import org.apache.struts.action.*;
import javax.servlet.*;
import com.devfirm.services.*;
import com.devfirm.formbeans.*;
/**
 *
 * @author Robbie
 */
public class AddContactUs extends Action{
    
    /** Creates a new instance of AddContactUs */
    public AddContactUs() {
    }
    
    public ActionForward execute(ActionMapping mapping,
                            ActionForm form,
                            ServletRequest request,
                            ServletResponse response)
    throws Exception {
        //Message.showInfo("Contact Us Action is Running");
        ActionForward forward = null;
        ContactUsService service = new ContactUsService();
        try {
            service.add(form);
            return mapping.findForward("success");
        }catch(Exception e) {
            return mapping.findForward("failure");
        }
    }
}

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://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
    <data-sources>
    </data-sources>

    <form-beans>
        <form-bean  name="contactUs"
                    type="com.devfirm.formbeans.ContactUs">
        </form-bean>
    </form-beans>

    <global-exceptions>
    </global-exceptions>

    <global-forwards>
    </global-forwards>

    <action-mappings>
        <action    
            path="/addContactUs"
            type="com.devfirm.actions.AddContactUs"
            name="contactUs"
            validate="false"
            input="/contactUs.jsp">
            <forward 
                name="failure" 
                path="/contactUs.jsp"/>
            <forward 
                name="success" 
                path="/contactUs.jsp"/>
        </action>
    </action-mappings>

    <message-resources  parameter="ApplicationResources"/>
</struts-config>

ContactUs.java:
*
 * ContactUs.java
 *
 * Created on May 25, 2005, 11:30 PM
 */

package com.devfirm.formbeans;
import org.apache.struts.action.*;
/**
 *
 * @author Robbie
 */
public class ContactUs extends ActionForm {
    
    /** Creates a new instance of ContactUs */
    public ContactUs() {
        //Message.showInfo("Contact Us Instantaniated");
    }

    private String companyName;
    private String contactName;
    private int contactPhone;
    private String contactEmail;
    private String industry;
    private String message;
    private String foundUsVia;
    
    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }

    public String getContactName() {
        return contactName;
    }

    public void setContactName(String contactName) {
        this.contactName = contactName;
    }

    public int getContactPhone() {
        return contactPhone;
    }

    public void setContactPhone(int contactPhone) {
        this.contactPhone = contactPhone;
    }

    public String getContactEmail() {
        return contactEmail;
    }

    public void setContactEmail(String contactEmail) {
        this.contactEmail = contactEmail;
    }

    public String getIndustry() {
        return industry;
    }

    public void setIndustry(String industry) {
        this.industry = industry;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getFoundUsVia() {
        return foundUsVia;
    }

    public void setFoundUsVia(String foundUsVia) {
        this.foundUsVia = foundUsVia;
    }
    
}

----- Original Message -----
From: "David G. Friedman" <hu...@ix.netcom.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Subject: RE: Action class defined in action-mappings not being executed - without 2mb webapp source
Date: Sun, 29 May 2005 03:15:07 -0400

> 
> Robbie,
> 
> I see you are using Struts v1.1 (your included DTD lists it as such) so are
> you using execute() or perform()?  What is your Action method's signature?
> 
> Regards,
> David
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org


-- 
_______________________________________________
NEW! Lycos Dating Search. The only place to search multiple dating sites at once.
http://datingsearch.lycos.com


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Action class defined in action-mappings not being executed - without 2mb webapp source

Posted by "David G. Friedman" <hu...@ix.netcom.com>.
Robbie,

Your execute() signature seems incorrect.  You use ServletRequest and
ServletResponse.  Try using HttpServletRequest and HttpServletResponse as
per the API.  The one you are using is not the default execute()
implementation for a web server.  See the descriptions of both execute()
methods on the Struts JavaDocs at:

http://struts.apache.org/api/org/apache/struts/action/Action.html

public ActionForward execute(ActionMapping mapping,
                             ActionForm form,
                             javax.servlet.ServletRequest request,
                             javax.servlet.ServletResponse response)
                      throws java.lang.Exception

The javadoc's note reads:

The default implementation attempts to forward to the HTTP version of this
method.

As for your DTD issues: your DTD looks correct according to what is written
in the top of the 1.2 DTD but my my copy of the Struts v1.2.4 blank/example
webapp's WEB-INF/struts-config.xml, lists an alternative DTD for 1.2.4 of:

<!DOCTYPE struts-config PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
          "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">

Regards,
David (off to work for the next 14 hours)

-----Original Message-----
From: Robbie Anonymous [mailto:robbie_listreply@lycos.com]
Sent: Sunday, May 29, 2005 6:52 AM
To: Struts Users Mailing List
Subject: RE: Action class defined in action-mappings not being executed
- without 2mb webapp source


I fixed the dtd to be struts 1.2 as thats the version of my struts.jar
(Struts 1.2.4).
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
              "-//Apache Software Foundation//DTD Struts Configuration
1.2//EN"
              "http://struts.apache.org/dtds/struts-config_1_2.dtd">
still doesnt work.

I'm using an execute() method and the code (along with method signature) is
below

/*
 * AddContactUs.java
 *
 * Created on May 26, 2005, 10:24 AM
 */

package com.devfirm.actions;

import org.apache.struts.action.*;
import javax.servlet.*;
import com.devfirm.services.*;
import com.devfirm.formbeans.*;
/**
 *
 * @author Robbie
 */
public class AddContactUs extends Action{

    /** Creates a new instance of AddContactUs */
    public AddContactUs() {
    }

    public ActionForward execute(ActionMapping mapping,
                            ActionForm form,
                            ServletRequest request,
                            ServletResponse response)
    throws Exception {
        //Message.showInfo("Contact Us Action is Running");
        ActionForward forward = null;
        ContactUsService service = new ContactUsService();
        try {
            service.add(form);
            return mapping.findForward("success");
        }catch(Exception e) {
            return mapping.findForward("failure");
        }
    }
}

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://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
    <data-sources>
    </data-sources>

    <form-beans>
        <form-bean  name="contactUs"
                    type="com.devfirm.formbeans.ContactUs">
        </form-bean>
    </form-beans>

    <global-exceptions>
    </global-exceptions>

    <global-forwards>
    </global-forwards>

    <action-mappings>
        <action
            path="/addContactUs"
            type="com.devfirm.actions.AddContactUs"
            name="contactUs"
            validate="false"
            input="/contactUs.jsp">
            <forward
                name="failure"
                path="/contactUs.jsp"/>
            <forward
                name="success"
                path="/contactUs.jsp"/>
        </action>
    </action-mappings>

    <message-resources  parameter="ApplicationResources"/>
</struts-config>

ContactUs.java:
*
 * ContactUs.java
 *
 * Created on May 25, 2005, 11:30 PM
 */

package com.devfirm.formbeans;
import org.apache.struts.action.*;
/**
 *
 * @author Robbie
 */
public class ContactUs extends ActionForm {

    /** Creates a new instance of ContactUs */
    public ContactUs() {
        //Message.showInfo("Contact Us Instantaniated");
    }

    private String companyName;
    private String contactName;
    private int contactPhone;
    private String contactEmail;
    private String industry;
    private String message;
    private String foundUsVia;

    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }

    public String getContactName() {
        return contactName;
    }

    public void setContactName(String contactName) {
        this.contactName = contactName;
    }

    public int getContactPhone() {
        return contactPhone;
    }

    public void setContactPhone(int contactPhone) {
        this.contactPhone = contactPhone;
    }

    public String getContactEmail() {
        return contactEmail;
    }

    public void setContactEmail(String contactEmail) {
        this.contactEmail = contactEmail;
    }

    public String getIndustry() {
        return industry;
    }

    public void setIndustry(String industry) {
        this.industry = industry;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getFoundUsVia() {
        return foundUsVia;
    }

    public void setFoundUsVia(String foundUsVia) {
        this.foundUsVia = foundUsVia;
    }

}

----- Original Message -----
From: "David G. Friedman" <hu...@ix.netcom.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Subject: RE: Action class defined in action-mappings not being executed -
without 2mb webapp source
Date: Sun, 29 May 2005 03:15:07 -0400

>
> Robbie,
>
> I see you are using Struts v1.1 (your included DTD lists it as such) so
are
> you using execute() or perform()?  What is your Action method's signature?
>
> Regards,
> David
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org


--
_______________________________________________
NEW! Lycos Dating Search. The only place to search multiple dating sites at
once.
http://datingsearch.lycos.com


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org