Contribution of Struts in WEB application development

previous-button-hisubmit-hi

 

Struts provide reusable flow control logic to the maximum possible extents for any kind of web application. It provides validation support, capturing user input. Struts framework doesn’t provide any code for presentation layer.

struts architecture

Architectural elements are as follows.

  1. ActionServlet: It belongs to controller layer. It is built in class given by struts framework, it is simple HttpServlet. Struts developer should also map every request to be passed via ActionServlet.
  2. FormBeans: It is used for view layer. FormBeans are also known as Action form
  3. Action Classes: It belongs to controller layer. In a struts application for each task we have to defined a user defined class that extends given Action class. An Action class perform the following duties.

1. Capturing user input from the form bean.

2. Invoking the business method of model layer.

3. Providing view information to the Action Servlet.

4. JSP’s: It belongs to view layer.

5. Struts-config.xml: It is used to establish relationship between controller and view layer, it doesn’t belongs to any layer

Flow control in struts application

Untitled Diagram

Ex. Schematic representation of a struts application in which end user entered account number into the web page and expecting account details.

Accounting Application: AccountInput.jsp, AccountFound.jsp, AccountNotFound.jsp, Exception.jsp, AccountForm.java, AccountAction.java, AccountService.java Struts-Config.xml, web.xml

Account

System requirements to develop and execute struts application:

  1. Install J2EE platform (jdk 1.6 or above)
  2. Install Tomcat 6.x.x or above.
  3. Install Struts 1.x and above.
  4. Install eclipse or NetBean IDE.

Steps to develop a struts application

  1. Creating structured hierarchy of directive.
  2. Developing model layer as knowing all properties of all the business method of service layer.
  3. Developing all the JSP of the application.
  4. Struts-config.XML development.

previous-button-hisubmit-hi

Share Button

Model View Controller (MVC) Architecture

previous-button-hisubmit-hi

 

What is MVC in connection with a web application ?

Any industry standard web application I.e. real time website uses three logic

  1. application logic
  2. Presentation logic
  3. Businesses logic

These three logic must be separated to get various benefit and to overcome various problems. Model, View & Controller is a solution for dividing these three logic. MVC is a design pattern that promote loose coupling between three concerns. It provides the following benefit

  1. Without effecting one concern with another we can develop application.
  2. Parallel development
  3. Re usability of code

According to MVC design pattern application logic in placed in controller, Presentation logic is view, and business logic in model. Representation of MVC in a real time web based enterprise application.

Controller receiving the client request, capturing the user input and performing server side validation for the user input.

Case 1: Validation failed controller identify appropriate input page and switch the control to that page.

Case 2: Validation Successful controller identifying the appropriate business component and it’s appropriate business method for data processing. Business method is executed and data is processed according to business rules of organization. Currently in industry the business method is belongs to either Spring Bean or EJB. Business method return the result to the controller.

MVC

 

Case 1: Processing is successful and the processed data is return to the controller.

Case 2: Requested data is not available and hence exception is generated to the controller.

Case 3: While processing data some abnormal events occur and this are propagated to the controller.

What is the drawbacks if we develop a web application without a framework ?

In a MVC based application, controller logic used for web application action is almost similar and difficult, if we develop application without framework then we need to develop controller for every application. A controller developed for one application can’t be reused for other application of same domain. If we develop controller without framework it is very time consuming job.

previous-button-hisubmit-hi

Share Button

Introduction to struts framework

submit-hi

What is Struts ?

Struts is not a web technology unlike servlets, JSP it is neither J2EE nor J2SE but it uses both technology, Struts is an open source web application framework from Apache Software Foundation (ASF). Struts is used for Java based interactive websites. Struts is used for developing presentation layer for a web enabled enterprise application. Struts application means a Java based web application that follows MVC design pattern & developed using struts framework. In any Java based web application, application logic is implemented in Java language & servlets JSP are used as web technology.

What is a web application framework?

A reusable & semi finished Web application that can be customized to produce a specific web application is known as application framework. Servlets, JSP, Java Bean are the Java technologies used in struts application.

How many logics a Java based web application contains?

Web application contains three logics

  1. Application logic
  2. Presentation logic
  3. Business logic

1. Application logic: It is a piece of code that is responsible for the following things is known as application logic.

  1. Receiving the client request
  2. Capturing the user input
  3. Performing server side validation for the user input.
  4. Invoking the business methods
  5. Making processed Data available to presentation logic.
  6. Identifying appropriate presentation logic & switching control to the logic.

2. Presentation logic: It is the piece of code that is responsible to generate the response for the client request is known as presentation logic, it is responsible for following things.

  1. Accessing memory data.
  2. Producing dynamic web page based on the data.

Note: Most of the times user input page is development is done by presentation logic.

3. Business logic: A piece of code that process Data according to business rules of organization is known as Business Logic.

Note: Struts developer is not responsible to develops Business Logic. Struts developer basically develop application logic and presentation logic. Struts framework provide support only in areas of application and presentation logic.

submit-hi

Share Button