If form bean is used to store the variables of the JSP form connected via action="submitDetailForm"
for example then what are ActionForm
s for?

- 49,761
- 33
- 66
- 176

- 15
- 5
-
This question should include more details and clarify the problem. – Roman C Sep 21 '22 at 09:44
-
I'm not 100% sure what you're asking; `ActionForm` is a form bean, it's for capturing, validating, and modifying form data. – Dave Newton Sep 21 '22 at 17:02
-
In other words, `submitDetailForm` is the `ActionForm`, which is the form bean. – Dave Newton Sep 21 '22 at 17:14
-
Thats what I was looking. Whats confusing about the app that I am working on is that it has a form which are actual beans but then a bean folder that parses the request result. – bugs account Sep 22 '22 at 20:16
-
@bugsaccount In other ways you can't use a form name in the `action` attribute. There should be a mapping to the Struts `Action`. – Roman C Sep 24 '22 at 20:36
-
@bugsaccount I'm not sure what "bean folder that parses the request result" means. – Dave Newton Sep 26 '22 at 16:23
1 Answers
Whats confusing about the app that I am working on is that it has forms that are actual beans but there's a bean folder that parses the request result.
Forms are mapped to the action. It doesn't matter which folder they belong. Sometimes classes for the form beans are in the same folder as action beans, sometimes the form beans are in the separate folder. Which folder is used you can find in the struts-config.xml
.
Everything becomes clear if you read Struts struts-config.xml action-mapping explained:
The
type
attribute of the<form-bean>
is used to enter FQCN of the bean class that would probably extend theActionForm
. It's needed by Struts to be able to instantiate a bean when required.
You can also read this article for quick overview of the framework Struts:
The
struts-config.xml
file can have several sections. The first section we will look at is the<action-mappings>
section.<action>
tells Struts which class to invoke from theActionServlet
. Only thepath
andtype
are required entries. Thetype
tells Struts whichAction
class to invoke when a URL with the model of thepath
is found.In order for a class to be entered in the
<action-mappings>
section and to be invoked byActionServlet
, it must extend the classorg.apache.struts.action.Action
(see Listing 3). TheActionServlet
will execute theperform()
method of theAction
object. The perform method looks like this:public ActionForward perform(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
The
ActionMapping
andActionForm
objects will contain information found in thestruts-config.xml
<action-mappings>
and<form-beans>
sections. TheHttpServletRequest
andHttpServletResponse
objects are from the servlet.

- 49,761
- 33
- 66
- 176