CS320 Web and Internet Programming MVC Architecture

Slides:



Advertisements
Similar presentations
Apache Struts Technology
Advertisements

 Copyright Wipro Technologies JSP Ver 1.0 Page 1 Talent Transformation Java Server Pages.
DT211/3 Internet Application Development JSP: Processing User input.
CS320 Web and Internet Programming Java Beans and Expression Language (EL) Chengyu Sun California State University, Los Angeles.
CS320 Web and Internet Programming Generating HTTP Responses
Apache Tomcat Server Typical html Request/Response cycle
Apache Struts Technology A MVC Framework for Java Web Applications.
UNIT-V The MVC architecture and Struts Framework.
Overview of JSP Technology. The need of JSP With servlets, it is easy to – Read form data – Read HTTP request headers – Set HTTP status codes and response.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Design Patterns Phil Smith 28 th November Design Patterns There are many ways to produce content via Servlets and JSPs Understanding the good, the.
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.
JAVA SERVER PAGES CREATING DYNAMIC WEB PAGES USING JAVA James Faeldon CS 119 Enterprise Systems Programming.
J2EE Overview Web Programming CSCI J2EE multi-tier architecture Servlet: Java class loaded into Web server JSP page: enhanced HTML page that is.
CS320 Web and Internet Programming Java Beans and Expression Language (EL) Chengyu Sun California State University, Los Angeles.
Chapter 2 An Overview of Servlet and JSP Technology.
JavaServer Faces (JSF) and Ajax Integration. Agenda 대강의 ( 정말로..) 개요 예제 아키텍트라면..
Model View Controller Architecture of Java Web Applications Dr. M V S Peri Sastry, Ph.D.[BITS-Pilani]
Fall 2007cs4201 Advanced Java Programming Umar Kalim Dept. of Communication Systems Engineering
Page 1 Controller Action2.java Struts- config. xml Mappings Business Logic Layer Data Layer View Layer Business Bean 1 Jsp Engine Jsp 1 Action3.java Action4.java.
CS320 Web and Internet Programming Introduction to Java Servlets Chengyu Sun California State University, Los Angeles.
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.
STRUCTURE OF JSP PRESENTED BY: SIDDHARTHA SINGH ( ) SOMYA SHRIVASTAV ( ) SONAM JINDAL ( )
Chapter 6 Chapter 6 Server Side Programming (JSP) Part 1 1 (IS 203) WebProgramming (IS 203) Web Programming.
JSP / Servlets and Beans
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.
A Presentation Presentation On JSP On JSP & Online Shopping Cart Online Shopping Cart.
CS320 Web and Internet Programming Introduction to Java Servlets Chengyu Sun California State University, Los Angeles.
CS520 Web Programming Spring – Web MVC Chengyu Sun California State University, Los Angeles.
CS3220 Web and Internet Programming Introduction to Java Servlets
CS520 Web Programming Servlet and JSP Review
Chengyu Sun California State University, Los Angeles
Structure of a web application
CS320 Web and Internet Programming Generating HTTP Responses
Output files generation
CS520 Web Programming Servlet and JSP Review
CS520 Web Programming Servlet and JSP Review
4166 Review.
Scripted Page Web App Development (Java Server Pages)
Design Patterns: Model View Controller
Chengyu Sun California State University, Los Angeles
CS5220 Advanced Topics in Web Programming Course Overview
Design and Maintenance of Web Applications in J2EE
Introduction to Struts
CS5220 Advanced Topics in Web Programming Spring – Web MVC
CS320 Web and Internet Programming Cookies and Session Tracking
CS320 Web and Internet Programming Expression Language (EL)
Java Server Pages (JSP)
CS320 Web and Internet Programming Java Beans
CS3220 Web and Internet Programming Cookies and Session Tracking
Chengyu Sun California State University, Los Angeles
CS3220 Web and Internet Programming Introduction to Java Servlets
CS3220 Web and Internet Programming Expression Language (EL)
Chengyu Sun California State University, Los Angeles
Chengyu Sun California State University, Los Angeles
Chengyu Sun California State University, Los Angeles
CS5220 Advanced Topics in Web Programming Angular – Services
CS3220 Web and Internet Programming Cookies and Session Tracking
Chengyu Sun California State University, Los Angeles
CS3220 Web and Internet Programming Expression Language (EL)
CS4961 Software Design Laboratory Understand Aquila Backend
Rules and Tips for Good Web Programming (and Programming in General)
Chengyu Sun California State University, Los Angeles
CS5220 Advanced Topics in Web Programming Course Overview
CS3220 Web and Internet Programming JavaScript Basics
CS5220 Advanced Topics in Web Programming Angular – Services
Chengyu Sun California State University, Los Angeles
Struts BY: Tejashri Udavant..
Presentation transcript:

CS320 Web and Internet Programming MVC Architecture Chengyu Sun California State University, Los Angeles

Java Web Application Servlets Beans JSPs Static resources Scripting elements, EL, JSTL Static resources HTML, CSS, images, … Metadata files web.xml, ...

Model 1 Architecture JSP + Bean Example JSP for presentation Bean for business logic Example GuestBook (Bean, EL, and JSTL)

Problems of Model 1 Architecture Using scripting elements mixes presentation and processing Hard to debug, maintain, or reuse code Not using scripting elements limits the interaction between presentation and processing to getters and setters Tedious to program Beans are no longer independent of the presentation layer, i.e. special getters/setters are needed

Improve Model 1 Architecture Application Presentation ?? Data Models Presentation Create UI Input and output JSP, JFC/Swing ... Data Models Independent of UI Bean (POJO) E.g. the GuestBookEntry class

Model 2 Architecture A.K.A. Model-View-Controller (MVC) Architecture Java Web Application View Controller Model JSP Servlet Bean

MVC in a Web Application ... model 2 controller 1 3 browser view 4 Client Server

... MVC in a Web Application Browser sends a request to controller Controller processes the request, updates some data Controller forwards the request and data to view View generates the response that is sent back to the client

Guest Book Example Using MVC Model GuestBookEntry.java View GuestBook.jsp, AddComment.jsp, EditEntry.jsp Redirect Controller GuestBook.java, AddComment.java, EditEntry.java

Forward Request From Controller to View request.getRequestDispatcher( “path_to_jsp" ) .forward( request, response );

Forward vs. Redirect servlet servlet browser browser jsp servlet request request. getRequest Dispatcher (“path_to_jsp”) .forward (request, response); response. sendRedirect (“another_url”) request response browser browser request response response request jsp servlet

Send Data From Controller to View Objects in application and session scope are shared by all servlets and JSPs of the application Additional data can be passed from servlet to JSP in request scope request.setAttribute( “objName”, obj ); request.getRequestDispatcher( “path_to_jsp" ) .forward( request, response );

More About the MVC Example One operation, one controller Requests always go to controllers first “Hide” JSPs under /WEB-INF/ Controllers do not generate HTML No out.println() JSPs are only used for display No scripting elements in JSP