SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.

Slides:



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

Apache Tomcat as a container for Servlets and JSP
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
18-Jun-15 JSP Java Server Pages Reference: Tutorial/Servlet-Tutorial-JSP.html.
JSP Java Server Pages Reference:
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.
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.
Java Servlet. What is Java Servlet? A Servlet is a java based server side web technology. It is a java class that serves a client request and receives.
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.
Department of Computer Science and Software Engineering Concordia University E NTERPRISE A PPLICATION D ESIGN P ATTERNS : I MPROVED AND A PPLIED Stuart.
Examples of Using Servlets and JSP Representation and Management of Data on the Internet.
Todd Snyder Development Team Lead Infragistics Experience Design Group.
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)
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.
CGS – 4854 Summer 2012 Web Site Construction and Management Instructor: Francisco R. Ortega Chapter 2.
SOEN 6011 Software Engineering Processes Section SS Fall 2007 Dr Greg Butler
CMPUT 391 – Database Management Systems Department of Computing Science University of Alberta CMPUT 391 Database Management Systems Web based Applications,
SOEN 6011 Software Engineering Processes Section SS Fall 2007 Dr Greg Butler
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.
Architectural Patterns Support Lecture. Software Architecture l Architecture is OVERLOADED System architecture Application architecture l Architecture.
Domain Driven Web Development With WebJinn Sergei Kojarski College of Computer & Information Science Northeastern University joint work with David H. Lorenz.
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.
Top right corner for field-mark, customer or partner logotypes. See Best practice for example. Slide title 40 pt Slide subtitle 24 pt Text 24 pt Bullets.
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.
Hints for Assignment #8. Initial Screen Hints for the initial page You need a DOCTYPE with the proper namespaces defined You need to import the facebook.
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.
Mark Dixon 1 11 – Java Servlets. Mark Dixon 2 Session Aims & Objectives Aims –To cover a range of web-application design techniques Objectives, by end.
Vakgroep Informatietechnologie – Onderzoeksgroep (naam) Web Centric Design of Distributed Software.
How CGI and Java Servlets are Run By David Stein 14 November 2006.
Servlets Hits Counter 20-Jul-18.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
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 2004 Instructor: Patrice Chalin.
Servlets and JSP 20-Nov-18 servletsJSP.ppt.
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 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.
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.
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 2005 Instructor: Patrice Chalin.
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.
Servlets.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
Servlets Servlets are modules that extend the functionality of a “java-enabled” web-server They normally generate HTML code and web content dynamically.
Java Servlets Servlet Overview Servlets and HTML Forms Servlet Basics
Introduction to Java Servlets
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.
Servlets Servlets are modules that extend the functionality of a “java-enabled” web-server They normally generate HTML code and web content dynamically.
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2004 Instructor: Patrice Chalin.
Presentation transcript:

SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin

Agenda – Lecture 10a Review & renew. Controller Patterns GRASP EA: Page and Front Controllers. A Spectrum of Web EA alternate designs. 12/1/2018 SOEN 343, © P.Chalin,

GRASP: Controller Who handles a system event? E.g. “List Movies” Main choices: assign to a design entity representing Overall system, or subsystem (façade controller). A Use Case scenario (often named, e.g. ListMovieHandler). 12/1/2018 SOEN 343, © P.Chalin,

GRASP: Controller Who handles a system event? E.g. “List Movies” Main choices: assign to a design entity representing Overall system, or subsystem (façade controller). A Use Case scenario (often named, e.g. ListMovieHandler). 12/1/2018 SOEN 343, © P.Chalin,

Presentation Domain Data Source Controller Patterns Page Controller Template View Presentation Front Controller Transform View Domain Model Transaction Script Domain Data Mapper Active Record Table Module Data Mapper Row Data Gateway Table Data Gateway Data Source Table Data Gateway 12/1/2018 SOEN 343, © P.Chalin,

Page Controller 12/1/2018 SOEN 343, © P.Chalin,

A1 Page Controllers protected void processRequest( HttpServletResponse response) throws ServletException, java.io.IOException // { TaskListHelper helper = new TaskListHelper(); try { ViewTaskListTS.execute(helper); } catch (Exception e) { helper.appendStatus(e.toString()); } if (helper.getTaskList() == null) { request.setAttribute("errorMessage", helper.getStatus()); forward("Error.jsp", request, response); } else { request.setAttribute("helper", helper); forward("TaskManager.jsp", request, response); 12/1/2018 SOEN 343, © P.Chalin,

A1 Page Controllers protected void processRequest(…) throws … { TaskListHelper helper = new TaskListHelper(); try { ViewTaskListTS.execute(helper); } catch (Exception e) { helper.appendStatus(e.toString()); } if (helper.getTaskList() == null) { request.setAttribute("errorMessage", helper.getStatus()); forward("Error.jsp", request, response); } else { request.setAttribute("helper", helper); forward("TaskManager.jsp", request, response); 12/1/2018 SOEN 343, © P.Chalin,

Page Controller vs. Front Controller – Differences in URL 12/1/2018 SOEN 343, © P.Chalin,

Page Controllers for A1 http:/stu.cs/343A1/ViewTaskList http:/stu.cs/343A1/AddTask http:/stu.cs/343A1/RemoveAllTasks … 12/1/2018 SOEN 343, © P.Chalin,

Front Controller for A1 Base URL: http:/stu.cs/343A1/frontController …/frontController ?command=ViewTaskList …/frontController ?command=AddTaskGrade&title=abc&… 12/1/2018 SOEN 343, © P.Chalin,

Front Controller 12/1/2018 SOEN 343, © P.Chalin,

Front Controller 12/1/2018 SOEN 343, © P.Chalin,

Front Controller (Fowler) Command (GoF) Patterns FrontCommand + init ( ) + processRequest ( ) RemoveStudentCommand ViewStudInfoCommand + processRequest ( ) + processRequest ( ) 12/1/2018 SOEN 343, © P.Chalin,

Front Controller: Sequence Diagram 12/1/2018 SOEN 343, © P.Chalin,

Front Controller: ProcessRequest 12/1/2018 SOEN 343, © P.Chalin,

Front Controller (cont’d) 12/1/2018 SOEN 343, © P.Chalin,

Front Controller: Advantages? 12/1/2018 SOEN 343, © P.Chalin,

Web EA Redesign Exercise Refactoring a DoItAll Servlet, let me count the ways … 12/1/2018 SOEN 343, © P.Chalin,

Do-it-all Servlet or Script Presentation Do-it-all Servlet or Script Domain Data Source 12/1/2018 SOEN 343, © P.Chalin,

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

Redesigning This Application Redesign DoItAll so as to increase the class cohesion. Create new classes. Which EA patterns would you use? Distribute the doGet() method code (given on the next slide) into the new classes. Identify which lines would go into which classes. 12/1/2018 SOEN 343, © P.Chalin,

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("<h1>Hello "+firstName+" "+lastName+"</h1>"); 12/1/2018 SOEN 343, © P.Chalin,

Do-it-all Servlet Redesign: Separating Concerns The next few slides show ways in which we can separate concerns; i.e. distribute the functionality of the do-it-all script into separate classes. Combinations other than the ones shown are possible. 12/1/2018 SOEN 343, © P.Chalin,

Redesigning Do-it-all (2 classes) [#1] Presentation Do-it-all redesign Domain Data Source Note: 12/1/2018 SOEN 343, © P.Chalin,

Redesigning Do-it-all (3 classes) [#3] Presentation Do-it-all redesign Domain Data Source 12/1/2018 SOEN 343, © P.Chalin,

Redesigning Do-it-all (4 classes) [#4] Presentation Do-it-all redesign Domain Data Source 12/1/2018 SOEN 343, © P.Chalin,

Redesigning Do-it-all : Adding … (5 classes) [#5] Presentation Do-it-all redesign Domain Data Source 12/1/2018 SOEN 343, © P.Chalin,

Redesigning Do-it-all : Adding … [#5b] Presentation Do-it-all redesign Domain Data Source 12/1/2018 SOEN 343, © P.Chalin,

Redesigning Do-it-all (5 classes) [#5c] Presentation Do-it-all redesign Domain Data Source Is there anything wrong with this design? (Hint: consider the dependencies and the layering style.) 12/1/2018 SOEN 343, © P.Chalin,

Redesigning Do-it-all (6 classes) [#6] Presentation Do-it-all redesign Domain Data Source 12/1/2018 SOEN 343, © P.Chalin,

Enterprise Application Patterns (v1.3) Page Controller Template View Presentation Front Controller Transform View Domain Model Transaction Script Domain Data Mapper Active Record Table Module Data Mapper Row Data Gateway Table Data Gateway Data Source Table Data Gateway 12/1/2018 SOEN 343, © P.Chalin,