80 likes | 97 Views
Create an ASP page that includes a welcome message component using cookies to display the username. The welcome message should be bold and say "Welcome, [username]!".
E N D
CSE 190: Internet E-Commerce Exam 2 Sample Questions
Exam 2 Sample • (3 pts) Write an ASP page main.asp that includes an ASP component welcome.asp in the body of the document. welcome.asp should be a bold div with the text “Welcome, <username>!” where <username> is the value of the cookie displayname. Be sure to show the contents of both files.main.asp:<html><head><title>My shopping site</title></head><body bgcolor=white><!--#include file=“welcome.asp” --></body></html>welcome.jsp:<div><b>Welcome, <%= request.Cookies( “displayname” ) %>!</div>
Exam 2 Sample 2. (2 pts) Explain the lifetime of objects created in JSP pages and what keywords control this scope. Create a Java bean named mybean in a JSP page that creates an instance of an object of class com.ebay.auctions. This instance lasts only as long as the browser’s request is being served.There are four major scopes for Java Beans in JSP:1. application: Object lives as long as the application (ie. web service) is running. Usually this is data that is specific to the entire site (e.g. site statistics, non-personalized information).2. session: Object lives as long as the user is actively using the application, which spans several requests. These objects contain user personalized data.3. request: Object lives as long as the request is being processed. This contains intermediate values used to calculate data for the user; it is accessible from any included JSP page.4. page: The object is visible only within the page it was created in.Example: <jsp:useBean id=“mybean” class=“com.ebay.auctions” scope=“session”/>
Exam 2 Samples 3. (2 pts) What’s the difference between session and persistent cookies? Show the HTTP header line in a server response that sets a persistent cookie.Persistent cookies are written to disk, and may still exist after the user closes and restarts the browser. Session cookies are discarded once the browser is closed. You would typically store a short lived session_id variable as a session cookie. Set-Cookie: lastlogin=celloplayer; expires=Sep 18, 2002;
Exam 2 Samples • (3 pts) Explain and diagram the model 2 architecture and its components.See lecture notes.
Exam 2 Sample 5. (2 pts) What are the consequences of changing state only in the app server’s process rather than committing the changes to a shared resource like a database?See lecture notes.
Exam 2 Sample 6. (3 pts) Write an application tier component for implementing a shopping cart. You must show the following objects: Cart and Item. Cart has methods addItem( Item ), removeItem( int ), and getItem( int ). Item has three properties Name, Price, and Status. Write a JSP page that renders the contents of the shopping cart. Then write the Java Beans that implement the functionality of Cart and Item. Note: You may use the class java.util.Vector, with the elements size(), elementAt(int), clear(), and removeElementAt(int).
Exam 2 Sample 7. (3 pts) Implement the shopping cart logic using PHP.See lecture notes.