Download presentation
Presentation is loading. Please wait.
Published byBetty Harrell Modified over 9 years ago
1
Case Study + MVC Lec - 39
2
Error Pages
3
By means of the page directive, a JSP can be given the responsibility of an Error page An Error JSP will be called by the Web Server when an uncaught exception gets generated The exception is passed as an instance of java.lang.Throwable to the Error JSP (accessible via implicit exception object)
4
Defining & Using Error Pages isErrorPage attribute of page directive is used to declare a JSP as an error page. JSP pages are informed about the error page by setting errorPage attribute of page directive.
5
Example Case Study Address Book using Model-1 architecture
6
Address Book ingredients Database
7
Address Book ingredients JavaBeans –PersonInfo Has attributes –name –address –phoneNum –PersonDAO Encapsulate Database logic Used to retrieve & save PersonInfo data
8
Address Book ingredients JavaServer Pages –addperson.jsp Used to collect new person info –saveperson.jsp Receives person info from addperson.jsp Saves it into database –searchperson.jsp Used to provide search criteria to search Person’s info, based on name –showperson.jsp Receives person name, to be searched in database Retrieves & display person records against that person name
9
Address Book ingredients JavaServer Pages (cont.) –Error Pages addbookerror.jsp –Identifies the type of exception –Displays the message associated with the received exception
10
Program Flow addperson.jsp saveperson.jsp showperson.jsp PersonInfo PersonDAO JavaBeans uses addbookerror.jsp exception searchperson.jsp
11
Lets put it all together Netbeans project addressbookusingmodel1
12
Model View Controller Design Pattern
13
Model-View-Controller Design Pattern MVC separates –Application data (contained in the model) from –Graphical presentation components (the view) & –Input/Event processing logic (the controller)
14
MVC in general modelview controller
15
MVC in general: model modelview controller Represents the state of the component (ie its data and the methods required to manipulate it) Independent of how the component is viewed or rendered
16
MVC in general: view modelview controller Appearance of the component Can be multiple views for the same model within a single applications Model may have different views in different applications or operating systems
17
MVC in general: controller modelview controller Dictates how a component interacts with events Sends events of interest to the model so that it can update itself
18
MVC in summary
19
Evolution of MVC Architecture No MVC 2.MVC Model 1 3.MVC Model 2 4.Web application framework (based on MVC model2) –Struts, Sun ONE application framework 5.Web application framework –JavaServer Faces (JSF)
20
MVC Model 1 Architecture
21
MVC Model 1
22
MVC Model 1 – A Detailed Story Client JSP Engine & Web Server JSP Engine & Web Server request JSP File JSP File request Call for component Component (JavaBean or EJB) Component (JavaBean or EJB) response Data response Compiled Servlet
23
MVC Model 2 Bean JSP JSP / Servlet Controller View Model
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.