File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes ActionForm returning null in ActionClass Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "ActionForm returning null in ActionClass" Watch "ActionForm returning null in ActionClass" New topic
Author

ActionForm returning null in ActionClass

charu latha
Ranch Hand

Joined: Aug 20, 2002
Posts: 67
I have a JSP page for which i have written an ActionClass as well as a FormBean.

I have made sure that my struts config file is showing the correct bean. However my form does not show up in the action class i always get a null. Any suggestions on why this could be happening?

<?xml version="1.0" encoding="ISO-8859-1" ?>

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

<!-- =====START:STRUTS CONFIGURATION FILE 1.1/EN================ -->

<struts-config>
<!-- =======START ata Source Configuration================= -->
<!--
<data-sources>
<data-source>
<set-propertyproperty="autoCommit"value="false"/>
<set-propertyproperty="description"value="Example Data Source Configuration"/>
<set-propertyproperty="driverClass"value="org.postgresql.Driver"/>
<set-propertyproperty="maxCount"value="4"/>
<set-property property="minCount"value="2"/>
<set-propertyproperty="password"value="mypassword"/>
<set-propertyproperty="url"value="jdbc ostgresql://localhost/mydatabase"/>
<set-propertyproperty="user"value="myusername"/>
</data-source>
</data-sources>
-->
<!-- =======END ata Source Configuration================ -->
<!-- ===========START: Form Bean Definitions=============== -->
<form-beans>
<form-bean name="registerationBean" type="com.zerodegrees.struts.forms.auth.RegisterFormBean" />
</form-beans>
<action-mappings>
<action path="/register"
type="com.zerodegrees.struts.actions.auth.RegisterAction"
name="registrationBean"
scope="session"
input="/views/auth/registration.jsp">
<forward name="success" path="/views/auth/registration.jsp" />
</action>
</action-mappings>

given above is part of my struts config file related to the jsp page i am dealing with.

html:form method="post" action="/register" name="registerForm" type="com.zerodegrees.struts.forms.auth.RegisterFormBean">

is the line is my jsp file

public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception
{
if (form != null) {
RegisterFormBean regForm = (RegisterFormBean)form;
System.out.println ("form is not null buddy");
String fname = regForm.getFirstName();
System.out.println ("the FIRSTNAME is " + fname);

}

return (mapping.findForward("success"));
}

is what i have written in the action class which i call RegisterAction.

public class RegisterFormBean extends ActionForm {

----------- is my bean in which i have getter and setter methods. Can anyone throw light on what i have done wrong for my form to return null?

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

Please ask Struts-specific questions in the Web App Frameworks forum. Moving this topic there.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ActionForm returning null in ActionClass
 
Similar Threads
HTTP Status 503 - Servlet action is currently unavailable
struts-config.xml file errors
Servlet action is not available
Struts validation framework- for single form, multiple actions
Database connection with struts