Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

ActionForm returning null in ActionClass

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 67446
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please ask Struts-specific questions in the Web App Frameworks forum. Moving this topic there.
 
Do you pee on your compost? Does this tiny ad?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic