JSP Architecture Outline  Model 1 Architecture  Model 2 Architecture.

Slides:



Advertisements
Similar presentations
Chapter 6 Server-side Programming: Java Servlets
Advertisements

4 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: Servlets.
3 Copyright © 2005, Oracle. All rights reserved. Designing J2EE Applications.
Web Development with Karsten Schulz Terp-Nielsen Master Principal Sales Consultant Oracle Denmark.
Java Server Pages (JSP)
Apache Struts Technology
 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
 Copyright Wipro Technologies JSP Ver 1.0 Page 1 Talent Transformation Java Server Pages.
J4www/jea Week 3 Version Slide edits: nas1 Format of lecture: Assignment context: CRUD - “update details” JSP models.
An introduction to Java Servlet Programming
June 1, 2000 Object Oriented Programming in Java (95-707) Advanced Topics 1 Lecture 10 Object Oriented Programming in Java Advanced Topics Servlets.
Layers & Tiers Umair Javed Lec - 41.
Integrating Servlets and JavaServer Pages Vijayan Sugumaran School of Business Administration Oakland University Parts of this presentation provided by.
Application Architectures Vijayan Sugumaran Department of DIS Oakland University.
Apache Struts Technology A MVC Framework for Java Web Applications.
CSCI 6962: Server-side Design and Programming History and Background.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
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.
Introduction to the Jakarta Struts Framework  The Topics: JavaServer Pages (JSP) Overview JSP Tags and Tag Libraries Overview Model – View – Controller.
Java Server Pages B.Ramamurthy. Topics for Discussion 8/20/20152 Inheritance and Polymorphism Develop an example for inheritance and polymorphism JSP.
Java Server Pages (JSP) Presented by: Ananth Prasad & Alex Ivanov May 10, 2001.
Netbeans – jsp.zip Introduction to JSP Netbeans – jsp.zip.
CIS 285 ROBINSON WINTER 2005 CIS 285 Web Application Development with Java CIS 285 Sinclair Community College Instructor: Mary Robinson.
1 Chapter 2 The Web Tier  Web Applications and Web ContainersWeb Applications and Web Containers  Dynamic Content CreationDynamic Content Creation 
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.
Design Patterns Phil Smith 28 th November Design Patterns There are many ways to produce content via Servlets and JSPs Understanding the good, the.
COMP 321 Week 7. Overview HTML and HTTP Basics Dynamic Web Content ServletsMVC Tomcat in Eclipse Demonstration Lab 7-1 Introduction.
Chapter 8 Script-free pages. Problem with scripting in JSP When you use scripting (declaration, scriplet, expressions) in your JSP, you actually put Java.
® IBM Software Group © 2007 IBM Corporation J2EE Web Component Introduction
JSF Introduction Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission.
Lecturer: Prof. Piero Fraternali, Teaching Assistant: Alessandro Bozzon, Advanced Web Technologies: Struts–
Case Study + MVC Lec Error Pages By means of the page directive, a JSP can be given the responsibility of an Error page An Error JSP will be called.
Webcommerce Computer Networks Webcommerce by Linnea Reppa Douglas Martindale Lev Shalevich.
Chapter 2 An Overview of Servlet and JSP Technology.
MVC Model 2 Architecture & AddressBook case study
Java Server Pages (JSP)
CSC 2720 Building Web Applications Frameworks for Building Web Applications.
A seminar on j2ee by saritha. s. What is J2EE J2EE (Java 2 Platform, Enterprise Edition) is a Java platform designed for the mainframe-scale computing.
 Obtaining a RequestDispatcher Forwarding requests from servlets to dynamic resources  Forwarding requests from servlets to static resources  Using.
Java Servlets and Java Server Pages Norman White Stern School of Business.
JSP Pages. What and Why of JSP? JSP = Java code imbedded in HTML or XML –Static portion of the page is HTML –Dynamic portion is Java Easy way to develop.
JSP BASICS AND ARCHITECTURE. Goals of JSP Simplify Creation of dynamic pages. Separate Dynamic and Static content.
1 Introduction to Servlets. Topics Web Applications and the Java Server. HTTP protocol. Servlets 2.
Advanced Java Session 6 New York University School of Continuing and Professional Studies.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Basic JSP Celsina Bignoli Problems with Servlets Servlets contain –request processing, –business logic –response generation all lumped.
Preface IIntroduction Objectives I-2 Course Overview I-3 1Oracle Application Development Framework Objectives 1-2 J2EE Platform 1-3 Benefits of the J2EE.
1 Copyright © 2004, Oracle. All rights reserved. Oracle Application Development Framework.
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.
Chapter 6 Chapter 6 Server Side Programming (JSP) Part 1 1 (IS 203) WebProgramming (IS 203) Web Programming.
 Java Server Pages (JSP) By Offir Golan. What is JSP?  A technology that allows for the creation of dynamically generated web pages based on HTML, XML,
APACHE STRUTS ASHISH SINGH TOMAR ast2124. OUTLINE Introduction The Model-View-Controller Design Pattern Struts’ implementation of the MVC Pattern Additional.
JSP / Servlets and Beans
OOSD Using Java CBTS Framework. 11/2/04CBTS2 Servlet  A servlet is a Java program that can extends Web server’s functionality.  Servlets interact with.
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.
A Presentation Presentation On JSP On JSP & Online Shopping Cart Online Shopping Cart.
CS 562 Advanced Java and Internet Application Computer Warehouse Web Application By Team Alpha :-  Puja Mehta (102163)  Mona Nagpure (102147)
Speaker Name Speaker Title Speaker Title Oracle Corporation Olivier Le Diouris Principal Product Manager Oracle Corporation Building Servlet and JSP Applications.
MODEL VIEW CONTROLLER PATTERN. Model View Controller MVC is a time tested method of separating the user interface of an application from its Domain Logic.
Introduction to Servlets
Java Servlets By: Tejashri Udavant..
Scripted Page Web App Development (Java Server Pages)
Unit 6-Chapter 2 Struts.
Design and Maintenance of Web Applications in J2EE
The Model Layer What is Model?
J2EE Lecture 1:Servlet and JSP
CS122B: Projects in Databases and Web Applications Winter 2019
Presentation transcript:

JSP Architecture Outline  Model 1 Architecture  Model 2 Architecture

Model 1 architecture  JSP-Centric Architecture –JavaBeans or EJB Model Objects –View JSP pages –Action JSP pages

Model 1 architecture

 In the Model 1 architecture, the incoming request from a web browser is sent directly to the JSP page, which is responsible for processing it and replying back to the client.  There is still separation of presentation from content, because all data access is performed using beans.

Person Example Program- Navigation Flow

Person Example Program – List Page  Presents a list of Person objects  Allows Edit and Create Operations

Person Example Program – Edit Page Typical HTML Form Page Displays Existing Model Object or Empty New Object

Model 1 Architecture - Overview  JSP Components Perform Display and Processing Tasks

Model 1 Architecture – Display Details View JSP Pages request model objects from business tier Standard JSP Tags used to display data <jsp:useBean id="person" class="com.wiley.compBooks.nyberg.ch02.objects.Person" scope="request">... person = PersonService.findPersonById(id); <INPUT TYPE="text" NAME="firstName" value=" " size="50"/>

Model 1 Architecture – Form/Submit Details  HTML Form is posted to unique Action JSP page  Other techniques include “Self Posting” and “Next-Page Posting”  HTTP Request Parameters extracted using setProperty with * <jsp:useBean id="person" class="com.wiley.compBooks.nyberg.ch02.objects.Person" scope="request" />  Action JSP page performs validation and model updates

Model 1 Architecture – Navigation Details  View JSP Pages hardcode links to other View pages  Action JSP Pages hardcode links to destination View pages // Return to form page if errors are encountered, leaving Person // on request if (errors.size()>0) { %> <% } else {... redirect(response,"./ShowPeople.jsp"); }

Model 1 Architecture – Summary Benefits of JSP-Centric Approach Drawbacks of JSP-Centric Approach Small number of components required to build a given application Architecture produces a tightly- coupled application with hard coded page names Small number of technologies, reducing learning curve for inexperienced resources Action JSP pages are primarily Java code, but cannot be developed, compiled, and debugged as easily as pure Java code Re-use of processing and validation logic is hampered by its placement in form-specific action JSP pages

Model 2 architecture  Servlet-Centric Architecture –JavaBeans or EJB Model Objects –View JSP pages –Servlet or Command Classes

Model-View-Controller  Model-View-Controller approach came from SmallTalk community - Involved notification/event models, direct manipulation of model objects  MVC today is basically a Tiered architecture -Interposes Controller components between View and Model components -Controller responsible for navigation, presentation-tier logic, validation -Emphasizes separation of presentation logic and model objects

Features  Clients do not request pages directly.  All clients requests go to a controller servlet.  Each request includes data: The requested action Any parameters for that action.  Controller servlet: Decides which page should be returned to user. Augments REQUEST (not response) object with additional data to be displayed to user.

Advantages  MVC approach simplifies JSP pages: No navigation code inside them. No complex data manipulation (db access, etc.)  Clean separation of presentation and processing logic.  The front components present a single point of entry into the application, thus making the management of application state, security, and presentation uniform and easier to maintain.  Multiple views using the same model

Model 2 Architecture

 The processing is divided between presentation (JSPs) and front components (controllers).  Presentation components are JSP pages that generate the HTML/XML response that determines the user interface when rendered by the browser.  Front components do not handle any presentation issues, but rather, process all the HTTP requests. They are responsible for creating any beans or objects used by the presentation components, as well as deciding, depending on the user's actions, which presentation component to forward the request to.  Front components can be implemented as either a servlet or JSP page.

Model 2 Architecture Issues  Single or Multiple controller servlets  Different views to be supported  Single functionality in page

Controller Responsibilities  Request processing  Creation of any beans or objects used by the presentation JSP  Deciding, depending on the user's actions, which JSP to forward the request to.  Data validation

Controller Design Poorly designed controller if (op.equals("createUser")) { model.createUser(request.getAttribute("user"), request.getAttribute("pass")); } else if (op.equals("changeUserInfo") { //... and so on... }

Controller Design Controller using Command Pattern public abstract class Action { protected Model model; public Action(Model model) { this.model = model; } public abstract String getName(); public abstract Object perform(HttpServletRequest req); }

Controller Design public class CreateUserAction extends Action { public CreateUserAction(Model model) { super(model);} public String getName() { return "createUser"; } public Object perform(HttpServletRequest req) { return model.createUser(req.getAttribute("user"), req.getAttribute("pass")); }

Controller Design public class ControllerServlet extends HttpServlet { private HashMap actions; public void init() throws ServletException { actions = new HashMap(); CreateUserAction cua = new CreateUserAction(model); actions.put(cua.getName(), cua); } public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {

Controller Design String op = getOperation(req.getRequestURL()); Action action = (Action)actions.get(op); Object result = null; try { result = action.perform(req); } catch (NullPointerException npx) { }

View Responsibilities  There is no processing logic within the presentation JSP itself: it is simply responsible for retrieving any objects or beans that may have been previously created by the Servlet, and extracting the dynamic content for insertion within static templates.

Sample View Best Available Flights <jsp:useBean id="customer" class="moreservlets.TravelCustomer" scope="session" /> Finding flights for <jsp:getProperty name="customer" property="frequentFlyerTable" />

Tag Libraries and M2 Client Controller Action JSP Page Dispatch forward Server side objects Tag libraries and business objects JSP page include