File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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"

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

<!-- =======START ata Source Configuration================= -->
<set-propertyproperty="description"value="Example Data Source Configuration"/>
<set-property property="minCount"value="2"/>
<set-propertyproperty="url"value="jdbc ostgresql://localhost/mydatabase"/>
<!-- =======END ata Source Configuration================ -->
<!-- ===========START: Form Bean Definitions=============== -->
<form-bean name="registerationBean" type="com.zerodegrees.struts.forms.auth.RegisterFormBean" />
<action path="/register"
<forward name="success" path="/views/auth/registration.jsp" />

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?

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63532

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

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: ActionForm returning null in ActionClass
It's not a secret anymore!