Escolar Documentos
Profissional Documentos
Cultura Documentos
Mangesh Agalawe Web Application Frameworks What is Struts Struts Application flow (Design with Detail)
Web Application
Stored on a server and delivered to users over the internet. Three- tier structure,
Comprising a User Service tier Business Service tier Data Service tier
Actual implementation of Design Patterns e.g. MVC Uses HTTP for its core communication protocol and delivers Web-based information to the user in the HTML language.
What is a Framework?
Reusable, semi-complete application that can be specialized to produce custom application A set of related architectural components Built on the common ground to provide a starting point Helps developers to focus on what the application needs so do instead how the application will do it
Advantages of framework
Reduces programming effort Increase performance Provide interoperability between APIs Reduce the effort required to learn APIs Reduce the effort required to design and implement APIs
What is Struts
An open source development framework for building web applications Based on Model-View-Controller (MVC) design paradigm Implementation of JSP Model 2 Architecture Created by Craig McClanahan and donated to Apache Software Foundation (ASF) in 2000 Approx 250 Classes and Interfaces
To develop the application in record time, but build them right and build them to last Struts is an open-source framework. Integrated with standard Java technologies and lets developers build web applications quickly and effectively
Struts Component
Controller
View
Action Servlet
Javax.servlet.http.HttpServlet Org.apache.struts.action.ActionServlet Plays a role of controller Controls flow of application in these steps:
Loads and instantiates proper beans Populates beans with the values from request parameters Passes bean to appropriate Action class Uses Action Forward from the result to determine the next view Handles errors
Action
Access the Business Layer. Used to process a request , via its execute() method, and return an ActionForward object that identifies where control should be forwarded. Prepare data objects for the presentation layer. They are invoke via their mapping in the strutsconfig.xml. They can create ActionErrors on failure, and return a forward to a mapping
Action Form
Pacage: org.apache.struts.action Java class that captures HTML form data in terms of properties Holds state of user data during validation Contains getter and setter methods Used by JSP to render data Has two levels of scope
ActionForm Methods
public ActionError validate (ActionMapping mapping,javax.servlet.ServletRequest request) public ActionError validate (ActionMapping mapping,javax.servlet.http.HttpServletRequest request) public void reset(ActionMapping mapping, javax.servlet.ServletRequest request) public void reset(ActionMapping mapping, javax.servlet.http.HttpServletRequest request)
Action class
import org.apache.struts.action.*; extends Action This class is going to specify what action is to be taken for a particular client request. In this class we have to give the definition of execute() method that tells what operations we have to perform on the database.