First Struts Application Development – Struts Tutorial

First Struts Application Development:- 

  • In the above app. Form bean is just taken to hold the form data of the form page.
  • The above application registers Action class as taken as model layer resource by directly placing business logic.
  • If form page or first page of Struts application is developed by using Struts supplied jsp tags then enabling <I-O-S> on ActionServlet is mandatory if same page is developed by using traditional html tags then enabling <I-O-S> on ActionServlet is optional.
  • VML parser is a software application i.e able to read & process XML documents.
  • ActionServlet (Struts framework) uses SAXparser to read & process Struts config. Uration file. Lly webserver / Servlet container also uses SAX-parser to read and process web.xml entries.

Note: – These xml parsers stores the data read from xml files in collection framework data Structures like hash table & uses then as needed in application execution.

  • When super class reference variable refers sub class object using that reference variable we can call the only methods of sub class that are present in super class and overridden or implemented sub class.
  • To make other operation also possible (calling direct methods of sub class) we need to type cast reference variable with sub class.
  • While working with Struts Action class always use ActionServlet supplied form bean class object (second parameter of execute method) bc3 this object contains form data of form page do not work with programmer created explicit new form bean object bc3 it never contains form data.

Example: –  public class test

              {

               public void (1)

                 {

                  ———

                  }

            }

      Public

Procedure to develop & deploy:

  • extract Struts-home \ apps \ Struts-blank-1.3.8.war file to temp folder by using winzip tool. (To gather xml, jar files)
  • extract Struts-home \ lib \ Struts-taglib-1.3.8.jar file to temp folder by using winzip tool. (To gather ltd files)
  • prepare the deployment directory structure of Struts application as shown below. 

The IO jar files of WEB-INF \lib folder you can collect from step1 extraction.
Gather Struts-html.ltd file from step2 extraction.

  • add TomCat-home \lib \Servlet-api.jar, Struts-home \lib \Struts-core-1.3.8.jar file to my computer class path variable to make java compiler (javac) recognize & working with Servlet-api, Struts-api.
  • compile the java source files of Struts application.

 Javac-d.*.java

  • development is completed.
  • start comeat server (Tomcat 5+)
  • deploy the Struts application in Tomcat server.

Copy E:\Struts Demo App1 Folder as to Tomcat-home\webapps folder.
Deployment is completed.
Test the application

http://local host:2020\StrutsDemoApp1\register.jsp

  • Setup used for the above application development.

      Jdk version (1.4+)

      Struts 1.3.8

      Tomcat 6.0 (5.0+)

  • In Struts application changes done in web.xml file.jsp.html programs will be recognized by underlying server automatically. Where as the changes done in Struts-config file will be recognized only after reloading the web application.
  • The Struts supplied jsp tags internally uses ActionServlet object & other Struts framework facilities during execution. So make sure that ActionServlet object is created by Servlet container before the execution of these tags for this we enable <I-O-S> on ActionServlet.
  • In the traditional html tags will not use ActionServlet obj. & Struts framework facilities during execution. So enabling <I-O-S> on ActionServlet while working with these tags is optional.
  • Since ActionServlet, our Struts application related form bean action classes residency two different packages we must take our form bean & action classes as public classes to make them visible to action Servlet & to allow ActionServlet for creating objects.
  • ActionServlet uses zero argument constructors internally while creating objects for our Form bean. Struts Action classes. So make sure that zero arg. Constructor is available if form bean, Struts Action classes directly / indirectly.
  • Taking care of every operation of a resource (java class) (from birth to death) is called as taking care of lifecycle operations.
  • Servlet container is responsible to take care of a life cycle of the Servlet jsp programs. ActionServlet takes care of the life cycle of Form bean, Struts Action class.
  • The modification done in java source of Struts application will be recognized by server only after recompilation of java source & reloading of the web application.

Leave a Reply

Your email address will not be published. Required fields are marked *