Case 6

Implementing the View

As a software engineer, your team has selected to implement the model 2 J2EE architecture. Your team has been assigned the task of implementing the full server side handling of the of the View layer for the Home Town Bank system as defined in the requirements document. This is to include handling of the http request from the browser using servlets and generating and returning the HTML fragments using JSP pages. These HTML fragments are to be embedded in the web pages via AJAX.

Return and Report

Servlets

  • Explain the Web-Tier Service Cycle defined in the Model 2 architecture.
  • Draw a UML State diagram illustrating the life cycle of a servlet.
  • How is information shared among collaborating web components?
  • What does the HTTPServletRequest class represent? What is it’s scope and life span?
  • What does the HTTPServletResponse class represent? What is it’s scope and life span?
  • What does the HTTPSession class represent? What is it’s scope and life span?
  • What does the ServletContext class represent? What is it’s scope and life span?
  • What does the PageContext class represent? What is it’s scope and life span?
  • What is the RequestDispatcher and how do you forward a request and response.
  • What information can a servlet retrieve from a request?
  • What information can a servlet send back to the browse via the HTTPServletResponse object?
  • The HTTPServlet class contains the following methods: init(), destroy(), doGet(), doPost(), doPut() and doDelete(). What is the purpose of each of the functions, who calls them and when are they called?
  • Walk through and explain a code snippet illustrating how a servlet can dynamically generate HTML and send it back to the client browser.
  • Walk thru and explain a code snippet of a servlet forwarding the request and response on to a different servlet, JSP or HTML page?

JSP

  • What implicit objects are created for a JSP page.
  • Give an example of a JSP declaration and explain its purpose.
  • Give an example of a JSP scriplet and explain its purpose.
  • Give an example of a JSP expression and explain its purpose.
  • Contrast the two different ways that you can including other web resources (e.g., JSP or HTML source) using JSP.

Design

Update the sequence diagrams for the these use cases you were working on in the previous case to use the model 2 J2EE architecture. Show all classes (i.e., Servlets, JSP pages, etc.) that you will be using in the sequence diagram to implement the View layer.

Implementation

Each member of the team is to implement one of the their assigned use cases using Servlets and JSP pages.

  1. Create servlets to handle the request for each use case. The servlet should get the parameters from the request, call the appropriate business methods, store the result as an attribute and forward the request and response to the appropriate JSP page.
  2. Create the JSP pages for the response. Each JSP page should dynamically generate the appropriate HTML using the data returned from theĀ  business methods defined for the control layer.
  3. Run the entire application illustrating the the functioning use cases .

Key Words

  • Model 2 Architecture
  • Servlet Request (HttpRequest)
  • Servlet Response (HttpResponse)
  • HTTP GET and HTTP POST
  • HTTP Parameters
  • Attributes

References

Published on October 29, 2008 at 5:10 pm Leave a Comment

The URI to TrackBack this entry is: http://rkjackson.wordpress.com/cases/case-6/trackback/

RSS feed for comments on this post.

Leave a Comment