Lecturer: Prof. Piero Fraternali, Teaching Assistant: Alessandro Bozzon, Advanced Web Technologies: Struts–

Slides:



Advertisements
Similar presentations
Web Development with Karsten Schulz Terp-Nielsen Master Principal Sales Consultant Oracle Denmark.
Advertisements

Apache Struts Technology
 Copyright Wipro Technologies JSP Ver 1.0 Page 1 Talent Transformation Java Server Pages.
Web MVC-2: Apache Struts Rimon Mikhaiel
MVC Frameworks Alternatives to coding the MVC pattern.
Struts1 Apache Struts Dr Jim Briggs. Struts2 What is Struts? Struts is an open source framework for building Java web applications Supports MVC/Model.
Sapana Mehta (CS-6V81) Overview Of J2EE & JBoss Sapana Mehta.
28/1/2001 Seminar in Databases in the Internet Environment Introduction to J ava S erver P ages technology by Naomi Chen.
Struts Basics SSE USTC Qing Ding. Agenda What is and Why Struts? Struts architecture – Controller: Focus of this presentation – Model – View Struts tag.
Satzinger, Jackson, and Burd Object-Orieneted Analysis & Design
Objectives:1. Investigate the Web application deployment descriptor 2. Install and deploy Tomcat and struts 3. Design and deploy a struts application Struts.
Application Architectures Vijayan Sugumaran Department of DIS Oakland University.
1 Java Server Pages Can web pages be created specially for each user? What part does Java play?
Apache Struts Technology A MVC Framework for Java Web Applications.
Session-01. Layers Struts 2 Framework The struts 2 framework is used to develop MVC-based web application. Struts 1.0 was released in June The.
Session-01. What is a Servlet? Servlet can be described in many ways, depending on the context: 1.Servlet is a technology i.e. used to create web application.
Web Applications Basics. Introduction to Web Web features Clent/Server HTTP HyperText Markup Language URL addresses Web server - a computer program that.
Introduction to Java web programming Dr Jim Briggs JWP intro1.
Apache Jakarta Tomcat Suh, Junho. Road Map Tomcat Overview Tomcat Overview History History What is Tomcat? What is Tomcat? Servlet Container.
Struts 2.0 an Overview ( )
Struts. Agenda Preface Struts and its components An example The architecture required for Struts Applications.
UNIT-V The MVC architecture and Struts Framework.
Lecture 2 - Struts ENTERPRISE JAVA. 2 Contents  Servlet Deployment  Servlet Filters  Model View Controllers  Struts  Dependency Injection.
JavaServer Faces: The Fundamentals Compiled from Sun TechDays workshops (JSF Basics, Web-Tier Codecamp: JavaServer Faces, Java Studio Creator; IBM RAD)
Chapter 10 EJB Concepts of EJB Three Components in Creating an EJB Starting/Stopping J2EE Server and Deployment Tool Installation and Configuration of.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
CSCI 6962: Server-side Design and Programming Course Introduction and Overview.
Java Omar Rana University of South Asia. Course Overview JAVA  C/C++ and JAVA Comparison  OOP in JAVA  Exception Handling  Streams  Graphics User.
Using JavaBeans and Custom Tags in JSP Lesson 3B / Slide 1 of 37 J2EE Web Components Pre-assessment Questions 1.The _____________ attribute of a JSP page.
JSP Architecture Outline  Model 1 Architecture  Model 2 Architecture.
Standalone Java Application vs. Java Web Application
8/15/2003System Specialists Corporation How to implement BC4J with the Struts Framework Eugene Sicat Technical Architect/Project Manager System Specialists.
CS4273: Distributed System Technologies and Programming Lecture 13: Review.
Struts J2EE web application framework “ Model 2 ” Model View Controller Controller Servlet Key features XML metadata Struts taglib Simplified form validation.
Webcommerce Computer Networks Webcommerce by Linnea Reppa Douglas Martindale Lev Shalevich.
J2EE Overview Web Programming CSCI J2EE multi-tier architecture Servlet: Java class loaded into Web server JSP page: enhanced HTML page that is.
Java Servlets & Java Server Pages Lecture July 2013.
Java Web Development with NetBeans IDE -- Kai Qian Chapter 5 JavaServer Faces (JSF) Technology.
1 MSCS 237 Overview of web technologies (A specific type of distributed systems)
Copyright © 2002 ProsoftTraining. All rights reserved. JavaServer Pages.
Struts Framework Anna Paščenko. What is Struts?  An open source framework for building Java web applications.
CSC 2720 Building Web Applications Frameworks for Building Web Applications.
Chính phủ điện tử TS. Phạm Văn Tính Khoa CNTT, ĐH Nông Lâm TP.HCM
Apache Struts. J2EE Web Application using MVC design pattern Why MVC? Separate components = easier maintenance – Model component holds object data – View.
Assignment of JAVA id : BSSE-F10-M-10-JAVA1 Overview of J2EE/Session 2/Slide 1 of 38.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Preface IIntroduction Objectives I-2 Course Overview I-3 1Oracle Application Development Framework Objectives 1-2 J2EE Platform 1-3 Benefits of the J2EE.
11 Copyright © 2004, Oracle. All rights reserved. Customizing Actions.
Chapter 3 JSP Overview. The Problem with Servlets processing the request and generating the response are both handled by a single servlet class Java programming.
1 Java Server Pages A Java Server Page is a file consisting of HTML or XML markup into which special tags and code blocks are inserted When the page is.
Chapter 9 Web Application Design. Objectives Describe the MVC design pattern as used with Web applications Explain the role and responsibilities of each.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
10 Copyright © 2004, Oracle. All rights reserved. Building ADF View Components.
APACHE STRUTS ASHISH SINGH TOMAR ast2124. OUTLINE Introduction The Model-View-Controller Design Pattern Struts’ implementation of the MVC Pattern Additional.
SDJ INFOSOFT PVT. LTD. 2 BROWSERBROWSER JSP JavaBean DB Req Res Application Layer Enterprise server/Data Sources.
Apache Struts Technology A MVC Framework for Java Web Applications.
1 Web Programming with Servlets & JSPs WEB APPLICATIONS – AN OVERVIEW.
A Presentation Presentation On JSP On JSP & Online Shopping Cart Online Shopping Cart.
V Web Tier Architecture MVC and Struts. v First, there were servlets And things were good Faster than CGI programs More scalable with built-in.
Enterprise Java v050228MVC1 Model, View, Controller Web Architecture.
Struts 2 Development. Topics  Roles in Struts Development  Control Flow  Actions  Struts 2 Views and Target  Struts 2 Custom Tags  Validation 
Java Servlets By: Tejashri Udavant..
Unit 6-Chapter 2 Struts.
Design and Maintenance of Web Applications in J2EE
MSIS 655 Advanced Business Applications Programming
The Model Layer What is Model?
JavaServer Faces: The Fundamentals
Struts BY: Tejashri Udavant..
SDMX IT Tools SDMX Registry
Presentation transcript:

Lecturer: Prof. Piero Fraternali, Teaching Assistant: Alessandro Bozzon, Advanced Web Technologies: Struts– Exercise Session

Summary Deployment Environment Some recap on Java Servlets Web Applications MVC2 Struts Exercises

Deployment Environment

Required Tools Java JDK 1.5 ~ 1.6 Eclipse IDE for Java EE Developers Tomcat 5.5 ~ 6.0.X Struts A database (e.g., Postgres) - optional

Recap

Servlet: analogous to CGI in the Java world  Servlet container: a Java program providing an execution environment for servlets  It provides Web server features as Java objects HTTP Request HTTP Response Browser Servlet container Applications (servlets) JVM parametri risposta Java Servlet

A Web application is a collection of servlets, documents and resources A Web application is sub-folder of the ervlet container’s webapps folder The name of the sub-folder is the name of the web applications  The Web.xml file is a deployment descriptor, as it configures the container Web applications It has a standard structure Locations: /web-app-name/WEB-INF/web.xml Libraries are stored under the /WEB-INF/lib folder Compiled Java classes are gathered under the /WEB- INF/classes folder All the resources/files contained in WEB-INF are not accessible from the Web browser Web application

Role of the presentation tier in Web based architectures In Web applications, the middle tier is the most complex software component Includes several functionalities Receives requests and send responses back Creates the user interface Implements the business logic and the interactions towards the data level

MVC and Web architectures In its classical version, MVC assumes The possibility of keeping track of the state of the application in the model The possibility to refresh the user interface when a change to the model state is notified Conversely, the HTTP protocol is stateless does not enable to automatically update a page displayed by the browser MVC needs to be adapted to the three-tier architecture employed for Web based applications  MVC 2

MVC2 for the Web based on Java MVC components are implemented exploting the Web architecture and Java J2EE API The client is a browser, requests and responses are HTTP The controller is a servlet, that processes all the requests The model is a set of Java classes (action and state objects) The view is a JSP page template

Struts 1 architecture Struts is an sophisticated implementation of the controller It is independent from the state implementation (state objects) and the page templates The link between the controller and the model is limited to specific Java classes called action classes

Controller: components Action servlet (provided by the framework): Base class: org.apache.struts.action.ActionServlet Implements the main functionalities of the controller Struts-config.xml (provided by the developer) XML configuration file of the controller:  Describes what action class shall be invoked for each request type  Specifies what view shall be invoked after an action is executed  Separates the control logic from the controller source code  Enables to modify the control flow by changing the configuration file Request Processor (provided by the framework): Available in Struts It is a helper class that provides methods needed by the ActionServlet

Action classes Interface class between the controller and the model In some cases considered as part of the controller, in others part of the model Goals: Hide details about the instantiation and invocation of business services Provide to the controller (actionServlet) a unique interface to be invoked (method execute() in Struts 1.1+, perform() in Struts 1.0) Receive the execution result from the business service and communicate it to the controller in a standard way

Communication controller-AC The controller invokes a unique method: public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response) throws Exception An ActionClass, when invoked, receives: The pair HTTP request/response HTTP (AC does not use the response !!) An ActionForm object that contains the user input (if existing) provided by means of a form An ActionMapping that enables communicating to the Controller the result of the ActionClass execution An ActionClass returns an ActionForward object that tells the Controller what to do

Controller configuration The controller makes two decisions: What action to be invoked for a given user request What view to be invoked for a given action termination The controller decides what to do based on mappings specified in the struts-config.xml file HTTP requests must be directed to the ActionServlet, defining in the web.xml file the correct servlet mapping

Model The Model contains business services needed to execute the application Struts is completely independent from the implementation of such services Model objects perform two functionalities Represent the application state (state objects) Implement the application logic (business objects)

State objects The application state can be represente by means of standard interface objects: JavaBeans Enterprise JavaBeans State can be volatile (i.e. Shopping cart) or durable (i.e.: received orders) Durability of the state requires a data-tier including one or more databases Database access can be implemented with different Java2EE technologies: JDBC Entity Enterprise Java Beans Java Data Objects

View Typically the View is composed by one or more JSP page templates that produce the pages displayed by the client browser Page templates publish the content of the model state objects The best practice to organize page templates is to use tag libraries Most used tag libraries Struts Tag Library Java Standard Tag Library (JSTL) Whenever possible, it is better to use Java standard library: JSTL

Typical components of a tag library JSP tag libraries contain four types of elements: Bean/Hierarchy tag: to access the content of JavaBeans or JavaBean hierarchies (i.e.: lists of lists) HTML tag: to increase the flexibility of HTML tags (i.e.: forms with memory and error checking) Logic tag: to avoid the use of scripting to express conditions (=, !=, strings comparison,..) and iterations Template tag: to dynamically fetch blocks of content and include them in the page

User’s input management Issue: in HTML/HTTP there is an element dedicated to data entry (form), but: User’s input is included in the HTTP request and must be extracted and processed by means of ad hoc code There is no way to express input validation in a standard way and enforce error checking There is no easy way to recall previous input when a form is refreshed (i.e. back button) Struts enables an advanced input management that eases the creation of applications

Struts input management principles Struts offers two functions to handle user input Objectification services: data inserted by the user are used to populate a Java object (called FormBean) Validation services: there is a framework to organize functions devoted to checking the correctness of input values and handle errors NOTE: In general, in MVC2 validation can be performed in three ways, not mutually exclusive:  At the client side (e.g., using JavaScript/FLASH/RIA…)  Using specific action classes (FormAction)  Using business services

Exercises