Enterprise Java v050228MVC1 Model, View, Controller Web Architecture.

Slides:



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

Apache Struts Technology
Java Servlet & JSP © copyright 2005 SNU OOPSLA Lab.
Using JavaServer Pages Harry R. Erwin, PhD CIT304/CSE301.
WEB1P servintro1 Introduction to servlets and JSP Dr Jim Briggs.
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.
J2EE Servlets and JSP Advanced topics Presented by Bartosz Sakowicz.
June 1, 2000 Object Oriented Programming in Java (95-707) Advanced Topics 1 Lecture 10 Object Oriented Programming in Java Advanced Topics Servlets.
Introduction to Servlet & JSP
Integrating Servlets and JavaServer Pages Vijayan Sugumaran School of Business Administration Oakland University Parts of this presentation provided by.
Apache Struts Technology A MVC Framework for Java Web Applications.
Servlet and JSP Programming: An Introduction Spiros Papadimitriou
Struts 2.0 an Overview ( )
Introduction to Struts 2.0 Jenny Ni Joey Feng Winddays Wang Hewmmi Zhu Heather Lv Software School,Fudan University 1.
Struts. Agenda Preface Struts and its components An example The architecture required for Struts Applications.
Struts:The good, the bad, the ugly A detailed evaluation of Struts 1.1 and Enterprise Web Applications. By Paul Smith Ancept, Inc. (
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.
Introduction Servlets and JSP Celsina Bignoli
Java Frameworks Indy Java Users Group January 29, 2003.
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.
JDeveloper 10g and JavaServer Faces: High-Performance UIs on the Web Avrom Roy-Faderman Senior Programmer May, 2006.
JSP Architecture Outline  Model 1 Architecture  Model 2 Architecture.
Standalone Java Application vs. Java Web Application
Web Server Programming 1. Nuts and Bolts. Premises of Course Provides general introduction, no in-depth training Assumes some HTML knowledge Assumes some.
Struts J2EE web application framework “ Model 2 ” Model View Controller Controller Servlet Key features XML metadata Struts taglib Simplified form validation.
Lecturer: Prof. Piero Fraternali, Teaching Assistant: Alessandro Bozzon, Advanced Web Technologies: Struts–
MDCFUG Is Java in Your Future? Tyler Williams Principal dataTerrace
Java Servlets & Java Server Pages Lecture July 2013.
Java Web Development with NetBeans IDE -- Kai Qian Chapter 5 JavaServer Faces (JSF) Technology.
CSC 2720 Building Web Applications JavaServer Pages (JSP) The Basics.
Domain Driven Web Development With WebJinn Sergei Kojarski College of Computer & Information Science Northeastern University joint work with David H. Lorenz.
JSF Framework Java Server Faces Presented by Songkran Totiya (6/10/2014)
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.
Fall 2007cs4201 Advanced Java Programming Umar Kalim Dept. of Communication Systems Engineering
 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.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Spring MVC Essentials Getting started.
1 Introduction to Servlets. Topics Web Applications and the Java Server. HTTP protocol. Servlets 2.
© 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.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 3 1COMP9321, 15s2, Week.
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.
©SoftMoore ConsultingSlide 1 Overview of Servlets and JavaServer Pages (JSP)
Java Servlets and Java Server Pages
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.
APACHE STRUTS ASHISH SINGH TOMAR ast2124. OUTLINE Introduction The Model-View-Controller Design Pattern Struts’ implementation of the MVC Pattern Additional.
Apache Struts Technology A MVC Framework for Java Web Applications.
CS320 Web and Internet Programming Web Application and MVC Chengyu Sun California State University, Los Angeles.
1 Web Programming with Servlets & JSPs WEB APPLICATIONS – AN OVERVIEW.
CS 562 Advanced Java and Internet Application Computer Warehouse Web Application By Team Alpha :-  Puja Mehta (102163)  Mona Nagpure (102147)
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.
Speaker Name Speaker Title Speaker Title Oracle Corporation Olivier Le Diouris Principal Product Manager Oracle Corporation Building Servlet and JSP Applications.
J2EE Platform Overview (Application Architecture)
Introduction Servlets and JSP
Handling Errors in Web Applications
Java Servlets By: Tejashri Udavant..
Unit 6-Chapter 2 Struts.
Introduction to Struts
The Model Layer What is Model?
JavaServer Faces: The Fundamentals
J2EE Lecture 1:Servlet and JSP
Introduction to Java Servlets
Struts BY: Tejashri Udavant..
SDMX IT Tools SDMX Registry
Presentation transcript:

Enterprise Java v050228MVC1 Model, View, Controller Web Architecture

Enterprise Java v050228MVC2 First, there were servlets And things were good Faster than CGI programs More scalable with built-in threading capability Value-added features –Request/Response, Sessions Full Java API access –JDBC, JMS, EJB, JavaMail, etc.

Enterprise Java v050228MVC3 Hmm, maybe not so good out.printlns in the code became tedious Takes a programmer to write HTML pages –Skill mismatch No automated tool support Mechanisms developed to output HTML pages –Inclusion of pages –htmlKona –Element Construction Set (ECS) There has to be a better way

Enterprise Java v050228MVC4 Then there were JSPs Page-centric view of the world Limited programmer involvement JSPs became ubiquitous for dynamic HTML page generation

Enterprise Java v050228MVC5 Model 1 Architecture Browser JSP Java Bean Database Custom Tags EJB

Enterprise Java v050228MVC6 Model 1 Architecture JSP-centric Suitable for small systems Susceptible to abuse –Excessive Java code in JSPs –Flow control issues

Enterprise Java v050228MVC7 Hybrid Approach Use servlets for flow-control; JSPs for HTML pages with dynamic content Allows programmer/web designer specialization Hybrid Approach=Model 2 Architecture A.K.A. MVC –Controller=Servlet+Helper Classes –Model=Application Data/Operations –View=Output Rendered for User

Enterprise Java v050228MVC8 Model 2 Architecture Browser JSP Java Bean Database Custom Tags EJB Servlet

Enterprise Java v050228MVC9 Model 2 Benefits Allows programmer to implement flow control, system operations in Java/Servlets Allows web page designers to develop HTML/JSP pages –Automated tool support Higher degree of re-use; more maintainable architecture for larger systems

Enterprise Java v050228MVC10 Struts ‘Standard’ MVC framework Struts 1.0 released in January 2001 MVC architecture with support for: –Configurable site navigation –Form handling –Internationalization –Extensive Custom tag libraries

Enterprise Java v050228MVC11 Struts Architecture Browser ActionServlet Action Mappings Action Database Bean View (Servlet/JSP/HTML)

Enterprise Java v050228MVC12 Struts Application Flow All requests are first processed by the action servlet Refers to ActionMappings to determine action to invoke –Calls Actions you’ve implemented for your application –Should be adapters to the rest of the application Action returns view to forward to View renders data placed in request or session scope by Action class

Enterprise Java v050228MVC13 A corej2ee MVC-light Struts and similar solutions provide for robust solutions –should be considered for most real implementations –Too little time to cover the details in this course Introduce MVC using a smaller-scale implementation –based on same similar MVC concepts –functional, but does not cover full array of issues involved in a Web-based development its simplicity makes understanding the MVC components possible within the scope of this course

Enterprise Java v050228MVC14 corej2ee.web Interfaces/Classes

Enterprise Java v050228MVC15 corej2ee.web.Controller public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{ String path=request.getServletPath(); try { Route route = navigation_.getRoute(path); String uri = unknownUri_; if (route != null) { Worker worker = route.getWorker(); Object result = worker.execute( getServletContext(),request,response); uri = route.getNextPage(result); } RequestDispatcher rd = getServletContext().getRequestDispatcher(uri); if (rd != null) { rd.forward(request, response); } else { response.sendError(HttpServletResponse.SC_NOT_FOUND, "unable to locate uri '" + uri + "' while handling path '" + path + "'"); }

Enterprise Java v050228MVC16 corej2ee.web.EnvEntryNavigator web.xml Configuration route/content-listPrincipals1/worker corej2ee.examples.principal.web.GetPrincipalsDAOWorker java.lang.String route/content-listPrincipals1/success /WEB-INF/content/showResult.jsp java.lang.String route/content-listPrincipals1/fail /WEB-INF/content/ErrorPage.jsp java.lang.String

Enterprise Java v050228MVC17 corej2ee.web.EnvEntryNavigator web.xml Configuration route/content-listPrincipals2/worker corej2ee.examples.principal.web.GetPrincipalsDAOWorker java.lang.String route/content-listPrincipals2/success /WEB-INF/content/printPrincipals.jsp java.lang.String route/content-listPrincipals2/fail /WEB-INF/content/ErrorPage.jsp java.lang.String

Enterprise Java v050228MVC18 corej2ee.examples.principal.web Workers

Enterprise Java v050228MVC19 corej2ee.examples.principal.web. GetPrincipalsDAOWorker public Object execute(ServletContext context, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Connection conn = null; try { conn = getConnection(); Collection principals = getDAO().findByWhere(conn, "1=1"); request.setAttribute(RESULT, principals); return SUCCESS; } catch (Exception ex) { request.setAttribute(ERROR_MESSAGE, ex.toString()); return ERROR; } finally { closeConnection(conn); }

Enterprise Java v050228MVC20 principalWEB showResult.jsp Show Result Results

Enterprise Java v050228MVC21 principalWEB showResult.jsp

Enterprise Java v050228MVC22 principalWEB printPrincipals.jsp List Principals Principals Collection principals = (Collection)request.getAttribute(Worker.RESULT); for(Iterator itr=principals.iterator(); itr.hasNext(); ) { itr.next() }

Enterprise Java v050228MVC23 principalWEB printPrincipals.jsp

Enterprise Java v050228MVC24 Resources