4) . Inner Communication in Struts
The communication between files or modules.
1. ActionServlet
2. JSP's
3. Web.xml
4. ActionBeans / FormBean
5. ActionClass
6. ActionForward
7. Struts Configuration file
1. ActionServlet : Builtin controller Servletof struts based web application this converts integration logic generated by framework software dynamically.
2. JSP's : View layer components having presentation logic it is recommended to develop JSP's of struts application as java less JSP's by using standard JSP's tags or JSP technologies,JSTL tags struts supplied JSP calass library tags and custom JSP tag library tags.
3.Web.xml : It is a deployment descripter file of web application having configuration of built in ActionServlet. This files also contains JSP tags library configuration, welcome file configuration.
Note: Even through ActionServlet is built in Servlet, its configuration in web.xml usingServlettags is mandatory.
Note: Struts based web applications are MVC architectured based web-applications and there will be one servlet in the entire web application, that is ActionServlet acting as controller.
4. ActionForm/FormBean: (it is a JavaBean class): It is a programmer developed java bean class as helper class to controller Servletcalled ActionServlet FormBean class object stores form data send by browse and received by ActionServlet.
FormBean class contains form validation logic. Form Bean is a JavaBean having capability to store form data.And also capable of validating form data.
A JavaClass/JavaBean class that extends from org.apache.struts.action.ActionForm is called FormBean class predefined ActionForm class is an abstract class containing no abstract methods.
Q : What is need of FormBean class in Struts application.
A : Verifying the format of the form data is called form validation.
5. ActionClass : (programmer supplied java class) : If business logic is kept directly in Action class then it acts as model. If Action class is having logic to interact with other model layer components/applicaitons like EJB components spring with Hibernate applications or any other business component, then Action class is called as helper to controller called ActionServlet.
Q : What is the need of ActionClass.?
A : If Business logic of struts based web application is available in EJB Component or in Spring with Hibernate application the controller Servletcalled ActionServlet is supposed to interact with these model Layer EJB components Spring with Hibernate applications. Since ActionServlet is builtin Servlet we can't place above said integration logic in ActionServlet. So we place this integration logic is the helper class to controller called ActionServlet . This helper class named as ActionClass.
6. Action-forward: This is an XML entry specifing result JSP page of Action class. Based on these configuration the business logic execution result goes to result JSP page, where the presentation logic of result JSP page formats the result and sends formatted result as response to the browser.
7. Struts configuration file :
Based on this files instuctional configurations the Action Servletwill decide FormBean , Action class to be utilize to process the request when action Servlet traps request given by the browser.
Entries kept in web.xml will be read by webContainer of webserver / application server. These entries kept in struts-configuration file will be read by struts frame work software and ActionServlet.
1. ActionServlet
2. JSP's
3. Web.xml
4. ActionBeans / FormBean
5. ActionClass
6. ActionForward
7. Struts Configuration file
1. ActionServlet : Builtin controller Servletof struts based web application this converts integration logic generated by framework software dynamically.
2. JSP's : View layer components having presentation logic it is recommended to develop JSP's of struts application as java less JSP's by using standard JSP's tags or JSP technologies,JSTL tags struts supplied JSP calass library tags and custom JSP tag library tags.
3.Web.xml : It is a deployment descripter file of web application having configuration of built in ActionServlet. This files also contains JSP tags library configuration, welcome file configuration.
Note: Even through ActionServlet is built in Servlet, its configuration in web.xml using
Note: Struts based web applications are MVC architectured based web-applications and there will be one servlet in the entire web application, that is ActionServlet acting as controller.
4. ActionForm/FormBean: (it is a JavaBean class): It is a programmer developed java bean class as helper class to controller Servletcalled ActionServlet FormBean class object stores form data send by browse and received by ActionServlet.
FormBean class contains form validation logic. Form Bean is a JavaBean having capability to store form data.And also capable of validating form data.
A JavaClass/JavaBean class that extends from org.apache.struts.action.ActionForm is called FormBean class predefined ActionForm class is an abstract class containing no abstract methods.
Q : What is need of FormBean class in Struts application.
A : Verifying the format of the form data is called form validation.
- In MVC based web applications this logic must be available in controller Servlet.Struts applications are MVC based web applications. And the built in controller Servletdoes not give any form validation logic an does not allow to keep form validation logic directly in it. But programmer wants to write form validation logic. For this struts frame work software makes ActionServlet to receive form data by trapping request and makes to store form data in user defined java class object. This user defined java class is nothing but FormBean class.
- Since FormData is visible and accessible in FormBean class the programmer also places form validation logic in FormBean Class.
5. ActionClass : (programmer supplied java class) : If business logic is kept directly in Action class then it acts as model. If Action class is having logic to interact with other model layer components/applicaitons like EJB components spring with Hibernate applications or any other business component, then Action class is called as helper to controller called ActionServlet.
Q : What is the need of ActionClass.?
A : If Business logic of struts based web application is available in EJB Component or in Spring with Hibernate application the controller Servletcalled ActionServlet is supposed to interact with these model Layer EJB components Spring with Hibernate applications. Since ActionServlet is builtin Servlet we can't place above said integration logic in ActionServlet. So we place this integration logic is the helper class to controller called ActionServlet . This helper class named as ActionClass.
As part of struts application flow of execution the request trapped by ActionServlet definitly tries to execute the logics of appropriate FormBean class, Action class once. The java class that extends from org.apache.struts.action.ActionServlet class is called Action class of struts application.
6. Action-forward: This is an XML entry specifing result JSP page of Action class. Based on these configuration the business logic execution result goes to result JSP page, where the presentation logic of result JSP page formats the result and sends formatted result as response to the browser.
7. Struts configuration file :
(any filename)(.xml file)
This xml file contains guidelines required for the ActionServlet, Framework software to generate Integration logic dynamically. This file contains FormBean classes configuration Action classes configuration,action-forward configurations and plugins configuration like validates plugins,files plugins.
Based on this files instuctional configurations the Action Servletwill decide FormBean , Action class to be utilize to process the request when action Servlet traps request given by the browser.
Entries kept in web.xml will be read by webContainer of webserver / application server. These entries kept in struts-configuration file will be read by struts frame work software and ActionServlet.
Any .xml can become struts configuration file but this file name must be informed to ActionServlet.
Reference Books:
Reference Books: