SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler

Slides:



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

 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
Introduction to Servlets Based on: Hall, Brown, Core Servlets and JavaServer Pages.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
Objectives Ch. D - 1 At the end of this chapter students will: Know the general architecture and purpose of servlets Understand how to create a basic servlet.
An introduction to Java Servlet Programming
2/16/2004 Dynamic Content February 16, /16/2004 Assignments Due – Message of the Day Part 1 Due – Reading and Warmup Work on Message of the Day.
Comp2513 Java Servlet Basics Daniel L. Silver, Ph.D.
Servlets Compiled by Dr. Billy B. L. Lim. Servlets Servlets are Java programs which are invoked to service client requests on a Web server. Servlets extend.
A Servlet’s Job Read explicit data sent by client (form data) Read implicit data sent by client (request headers) Generate the results Send the explicit.
CSCI 6962: Server-side Design and Programming History and Background.
Java Servlets. What Are Servlets? Basically, a java program that runs on the server Basically, a java program that runs on the server Creates dynamic.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
Struts 2.0 an Overview ( )
XML for E-commerce IV Helena Ahonen-Myka. In this part... n Some solutions for delivering dynamic content n Example of using XML.
Design I: Web Application Architecture and Patterns Peter Dolog dolog [at] cs [dot] aau [dot] dk Intelligent Web and Information Systems September.
Domain Logic Patterns  Transaction Script  Domain Model  Table Module  Service Layer.
What is Architecture  Architecture is a subjective thing, a shared understanding of a system’s design by the expert developers on a project  In the.
Examples of Using Servlets and JSP Representation and Management of Data on the Internet.
Servlets. - Java technology for Common Gateway Interface (CGI) programming. - It is a Java class that dynamically extends the function of a web server.
Java support for WWW Babak Esfandiari (sources: Qusay Mahmoud, Roger Impey, textbook)
Chapter 5 Java Servlets. Objectives Explain the nature of a servlet and its operation Use the appropriate servlet methods in a web application Code the.
Java Servlets and Java Server Pages Carol Wolf Computer Science.
J2EE training: 1 Course Material Usage Rules PowerPoint slides for use only in full-semester, for-credit courses at degree-granting.
111 Java Servlets Dynamic Web Pages (Program Files) Servlets versus Java Server Pages Implementing Servlets Example: F15 Warranty Registration Tomcat Configuration.
JSP Architecture Outline  Model 1 Architecture  Model 2 Architecture.
 Embeds Java code  In HTML tags  When used well  Simple way to generate dynamic web-pages  When misused (complex embedded Java)  Terribly messy.
COMP 321 Week 7. Overview HTML and HTTP Basics Dynamic Web Content ServletsMVC Tomcat in Eclipse Demonstration Lab 7-1 Introduction.
CMPUT 391 – Database Management Systems Department of Computing Science University of Alberta CMPUT 391 Database Management Systems Web based Applications,
Chapter 3 Servlet Basics. 1.Recall the Servlet Role 2.Basic Servlet Structure 3.A simple servlet that generates plain text 4.A servlet that generates.
MDCFUG Is Java in Your Future? Tyler Williams Principal dataTerrace
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
Mark Dixon 1 09 – Java Servlets. Mark Dixon 2 Session Aims & Objectives Aims –To cover a range of web-application design techniques Objectives, by end.
Spring 2009Computer Science Department, TUC-N Object Oriented Methods Architectural Patterns 3.
Architectural Patterns Support Lecture. Software Architecture l Architecture is OVERLOADED System architecture Application architecture l Architecture.
Pertemuan 10 Enterprise Application Patterns Mata kuliah: T0144 – Advanced Topics in Software Engineering Tahun: 2010.
Saving Client State Session Tracking: Maintain state about series of requests from same client over time Using Cookies: Clients hold small amount of their.
20-Nov-15introServlets.ppt Intro to servlets. 20-Nov-15introServlets.ppt typical web page – source Hello Hello.
S ERVLETS Hits Counter 21-Nov-15. S ERVLETS - H ITS C OUNTER Many times you would be interested in knowing total number of hits on a particular page of.
Server-side Programming The combination of –HTML –JavaScript –DOM is sometimes referred to as Dynamic HTML (DHTML) Web pages that include scripting are.
Data Source Patterns.  Table Data Gateway  Row Data Gateway  Active Record  Data Mapper  Unit of Work  Identity Map.
 Registry itself is easy and straightforward in implementation  The objects of registry are actually complicated to store and manage  Objects of Registry.
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.
 2002 Prentice Hall. All rights reserved. 9.8 Multi-Tier Applications: Using JDBC from a Servlet Three-tier distributed applications –User interface –Business.
Middleware 3/29/2001 Kang, Seungwoo Lee, Jinwon. Description of Topics 1. CGI, Servlets, JSPs 2. Sessions/Cookies 3. Database Connection(JDBC, Connection.
SOEN 6011 Software Engineering Processes Section SS Fall 2007 Dr Greg Butler
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, Responds oriented other.
1 Introduction to Servlets. Topics Web Applications and the Java Server. HTTP protocol. Servlets 2.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 3 1COMP9321, 15s2, Week.
Vakgroep Informatietechnologie – Onderzoeksgroep (naam) Web Centric Design of Distributed Software.
CSC 2720 Building Web Applications Basic Frameworks for Building Dynamic Web Sites / Web Applications.
©SoftMoore ConsultingSlide 1 Overview of Servlets and JavaServer Pages (JSP)
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 21 Java Servlets Wed. 11/22/00 based on material.
HTTP protocol Java Servlets. HTTP protocol Web system communicates with end-user via HTTP protocol HTTP protocol methods: GET, POST, HEAD, PUT, OPTIONS,
Bayu Priyambadha, S.Kom. Static content  Web Server delivers contents of a file (html) 1. Browser sends request to Web Server 3. Web Server sends HTML.
MVC Architecture, Symfony Framework for PHP Web Apps
JDBC & Servlet CSE 4504/6504 Lab.
Scripted Page Web App Development (Java Server Pages)
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
Enterprise Architecture Patterns
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
Java Servlets Servlet Overview Servlets and HTML Forms Servlet Basics
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
Presentation transcript:

SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler

Outline Data Gateways –GetByLastNameEA Enterprise Applications: –SoenEA framework and samples. Controller patterns –Focus: Page Controller

Domain Data Source Table Data Gateway Transaction Script Domain Model Data Mapper Row Data Gateway Front Controller Template View Transform View Page Controller Presentation Active Record Enterprise Application Patterns

Domain Data Source Table Data Gateway Transaction Script Domain Model Data Mapper Row Data Gateway Active Record Front Controller Template View Transform View Page Controller Presentation Data Source Patterns

Row Data Gateway An object that acts as a single record in the data source –There is one instance per row Fowler RDG combines two roles Class …Finder with find(id):Gateway method which returns the ‘object’ Class …Gateway which is the ‘object’ Our PersGradeRDG (next slide) combines

Row Data Gateway PersGradeRDG - name : String - grade : int + PersGradeRDG(name, grade) + find(name) : PersGradeRDG + insert() : void + update() : void + delete() : void + … getters and setters …

Row Data Gateway: Find Code

Row Data Gateway Code sample for Fowler’s PersonRDG Note ‘find’ method is static –it is class method

GetByLastName Example Simple web application to Input a student’s last name Fetch database record Output student’s full name

GetByLastName Will look at Row Data Gateway PageController Transaction Script

Row Data Gateway StudInfoRDG –Represents record in DB of student StudInfoFinder –Finds student record based on lastName –Returns the StudInfoRDG –Locates DB using DBRegistry

Outline Enterprise Applications: –SoenEA framework and samples –Simple sample: GetByLastName –Builds on HelloWeb

Package structure

Domain Data Source Table Data Gateway Transaction Script Domain Model Data Mapper Row Data Gateway Front Controller Template View Transform View Page Controller Presentation Active Record Enterprise Application Patterns

Transaction Script Fowler: A TS organizes the business logic primarily as a single procedure where each procedure handles a single request from the presentation. The TS may make calls directly to the DB or through a thin DB wrapper. Think of a script for: a use case or business transaction. Implementation can be –shared among subroutines. –Subroutines can be used by more than one script

Transaction Script … is essentially a procedure that takes the –input from the presentation, –processes it with validations and calculations, –stores data in the database, –(invokes any operations from other systems, and) –replies with more data to the presentation perhaps doing more calculation to help organize and format the reply data. (Fowler)

GetByLastName Will look at Row Data Gateway PageController Transaction Script

Do-it-all Transaction Script A TS that does all the work itself Without a Finder Without a RDG Directly calls DB

Do-it-all Servlet or Script, Class public class DoItAll extends javax.servlet.http.HttpServlet { protected void doGet( HttpServletRequest request, HttpServletResponse response) throws... // { … }

Do-it-all Transaction Script, doGet() String lastName = request.getParameter(“…"); Connection dbc = DbRegistry.getDbConnection(); String findSql = " SELECT * from … where LastName = ? ”; PreparedStatement dbQuery = dbc.prepareStatement(findSql); dbQuery.setString(1, lastName); ResultSet rs = dbQuery.executeQuery(); rs.next(); String firstName = rs.getString( "FirstName" ); lastName = lastName.toUpperCase(); PrintWriter out = response.getWriter(); response.setContentType("text/html"); out.println( " Hello "+firstName+" "+lastName+" " );

Outline Controller patterns –Focus: Page Controller

Domain Data Source Table Data Gateway Transaction Script Domain Model Data Mapper Row Data Gateway Active Record Front Controller Template View Transform View Page Controller Presentation Controller Patterns

Page Controller Fowler: A Page Controller is an object that handles a request for a specific page or action on a web site. There is one input controller for each logical page of the web site. Page Controller handles the http get and post Decides which model and view to use

Page Controller Responsibilities: –Decode the URL, extract any form data, decide action –Create and invoke any model objects All relevant data from the html request should be passed to the model, so the model does not need any connection to html request –Determine which view should display the result page Forward model information to it Helper objects can be created/used to perform tasks that are shared

Page Controller Fowler Example: display info about a recording artist –ActionServlet implements common ‘forward’ task –ArtistController implements doGet() Checks artist name is ok Creates a new ArtistHelper object with Artist as attribute Adds helper information to html request Forwards request to Artist.jsp –Artist.jsp is a TemplateView which gets information to display from helper object (which it gets from request)

Page Controller

GetByLastName Will look at Row Data Gateway PageController Transaction Script

Page Controller SOEN EA sample: display info about a student –PageController implements doGet() Delegates to transaction script Note: does not follow Fowler’s use of.jsp delegates rather than forwards no explicit helper object (really StudInfoRDG is helper)