Download presentation
Presentation is loading. Please wait.
1
CSE 190: Internet E-Commerce Lecture 8
2
Application Tier Architecture Model View Controller pattern Model 2 architecture Statelessness of application tier Interaction with data tier Interaction with presentation tier Validation components
3
Model View Controller (MVC) MVC: Design used when you have many different views of the same data –Model: The entity that represents some object –View: A visualization of that entity –Controller: A set of functions for changing the state of a model Example: Spreadsheet –Model: The spreadsheet table –View: A chart created from the data –Controller: The user interface that allows you to change the data in the table
4
Model 1: Simple JSP pages with helper classes The JSP page serves content by accessing an object exposed by the Java Bean (a simple class)
5
Model 2 Architecture: MVC applied to the application tier A single servlet controls all the requests coming in to the site. Controller functions: –Validate input –Change model state –Forward to the view View –JSP simply renders the resulting page; read only operations
6
Application Tier: Stateless Application tier: designed to be stateless Allows any app server to fail, and we can replace it with an identical server Any state that is kept in the app server should be cache state (typically read-only)
7
App Tier: Talks to Data Tier Class ShoppingCart { EntityShoppingCart _cart; ShoppingCart( int userId ) { _cart = EntityShoppingCart(userId); } String getDescription( int itemNum ) { return _cart.getItem( itemNum ).getDescription(); } …. }
8
Presentation Tier: Talks to App Tier Should never need to execute code more complex than a simple method call within presentation tier
9
Validation components Servlet controller: Usually two parts –Validator –Command object First, parsed input from forms is passed to a form validator object –On failure, forward to error page Then apply designed command object Finally, forward to view page
10
Exam 1.(2 pts) Explain the purpose of each tier of a web service. Draw a diagram illustrating the components of each tier. Briefly note the purpose of each component.
11
Exam 2.(2 pts) Write the URL that represents a request to the machine www.yourbusiness.com getting document /cgi-bin/render with two arguments: address1 with value “9500 Gilman Drive”, address2 with value “La Jolla, CA 92093”. (Quotes are not part of the value.) www.yourbusiness.com
12
Exam 3.(3 pts) Write the HTML for a form that will collect this input from the user and allow them to submit it to the URL above.
13
Exam 4.(3 pts) Explain why you might use a stylesheet to position HTML elements rather than a borderless HTML table acting as a container. Write an HTML file with an internal stylesheet that applies an italic font-style and 24pt font-size to all H1 and H2 elements on the page.
14
Exam 5.(2 pts) Write an HTML page that uses Javascript to write the current date at the end of the document, using the built in Date() function.
15
Exam 1 6.(2 pts) Write the Javascript code to display the innerHTML of the first form of an HTML page.
16
Exam 7. (3 pts) Show the complete request and response issued when an HTTP/1.0 client requests the HTML document /index.asp from the HTTP/1.1 server at www.hotdog.com. Indicate when the connection closes. www.hotdog.com
17
Exam 8.(3 pts) Explain the relationship between parent and children processes in Apache. What is the rationale for this relationship?
18
Exam 9. Bonus: (2 pts) Given the settings below in httpd.conf, what is the exact pathname of the file retrieved by http://mysite.com:8080/user/ski/home.asp ?http://mysite.com:8080/user/ski/home.asp NameVirtualHost * ServerAdmin sinala@gremlin.ucsd.edu DocumentRoot "/home/sinala/apache/htdocs" ServerName gremlin.ucsd.edu ErrorLog logs/error_log CustomLog logs/access_log common ServerAdmin webmaster@mysite.com DocumentRoot "/home/sinala/apache/htdocs/mysite" Port 8080 ServerName mysite.com ErrorLog logs/mysite-error_log CustomLog logs/mysite-access_log common
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.