52mvc-2up - 52 MVC 04 Nov 2010 CSCC09F Programming on the...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
52 MVC 04 Nov 2010 CSCC09 Programming on the Web 1 52 MVC CSCC09 Programming on the Web 1 Web Application Architecture: Model-View-Controller (MVC) CSCC09F Programming on the Web 52 MVC CSCC09 Programming on the Web 2 JSP b Have we solved the println problem? b Does this kind of code scale up? Could we write a serious business application by mixing up HTML and Java with the Servlet API like this? <html> <body> <% int fact = 1; for (int i=1; i<=10; ++i) { fact *= i; %> <p>Factorial of " <%= i %> is <%= fact %> </p> <% } %> </body> </html>
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
52 MVC 04 Nov 2010 CSCC09 Programming on the Web 2 52 MVC CSCC09 Programming on the Web 3 Scaling Up: MVC Architecture b To build enterprise-scale J2EE applications we need to make several changes c reduce the amount of business logic present in JSP pages – they should be about presentation – the View component of the app which provides viewable pages for state and events c move business logic to backend Servlets that are good at this task – the Controller component of the app c store persistent system state in a RDBMS – the data model component of the app b MVC: the Model-View-Controller architecture is the most popular for Servlet-based systems 52 MVC CSCC09 Programming on the Web 4 What is MVC Architecture? b Consists of: c A data model representing the application’s persistent state c A presentation component that makes state information viewable by the user and may respond to events c The “business logic” that implements the systems rules and control flow. b Is there an established pattern that could guide how these standard elements are assembled into an application b Can we standardize so that we don’t have to build the same framework for each new application?
Background image of page 2
52 MVC 04 Nov 2010 CSCC09 Programming on the Web 3 52 MVC CSCC09 Programming on the Web 5 Scaling Up: MVC Architecture b How does MVC architecture apply to Servlets? b JSP will play the View role, but how does it interact with the rest of the system? b Servlets will implement the Controller, the business logic, but how do they interact with the Model and View? b A RDBMS implements the Model, but how does the controller change it and how does its state migrate out to the View? 52 MVC CSCC09 Programming on the Web 6 Model-Controller: JDBC b In tutorial you have already looked at some JDBC example code – we will cover it in class later b JDBC allows a Servlet to talk SQL to a database: queries, updates, structural changes such as adding or changing tables, etc. b JDBC provides a way for the Controller to change and query the Model b As an abstraction of database functionality it does a good job b However, when OO code and SQL are mixed together the results are less impressive
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
52 MVC 04 Nov 2010 CSCC09 Programming on the Web 4 52 MVC CSCC09 Programming on the Web 7 Model-Controller: JDBC b What is wrong with embedding SQL statements into the Controller (Servlets)? b
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/09/2010 for the course CS CSCC09 taught by Professor Alan during the Spring '10 term at University of Toronto- Toronto.

Page1 / 11

52mvc-2up - 52 MVC 04 Nov 2010 CSCC09F Programming on the...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online