Docsity

Java Server Pages Design: Page-Centric vs Dispatcher Design, Study notes of Software Engineering

Partial preview of the text

Download Java Server Pages Design: Page-Centric vs Dispatcher Design and more Study notes Software Engineering in PDF only on Docsity!

Java Server Pages Design

Ye Wu http://www.ise.gmu.edu/~wuye/ SWE 642 Software Engineering for the World Wide Web

sources: Professional Java Server Programming, Patzer, Wrox, Ch 11, 14

Web Application Architecture

Servlet JSP JavaBean

Move Business Logic backward to JavaBeans

Move control forward to Java Servlets

11/24/2003 © Dr. Wu and Dr. Offutt 3

Design Styles

  1. Page-centric (client-server) : Requests are made to JSP pages, and the JSP pages respond to clients
  2. Dispatcher (N-tier) : Requests are sent to JSPs or servlets that then forward the requests to another JSP or servlet

In both cases, the goal is to separate logic from presentation and to separate as many concerns in the logic as possible.

1) Page-centric Design

Browser on a client

Browser on a client

Browser on a client

Server

Client requests areJSP or servlets^ Database intercepted here

EJB Java Beans

Uses or instantiates

Request Response

11/24/2003 © Dr. Wu and Dr. Offutt 7

1-B) Page-View with Bean Design

  • When more business processing and data access is needed
  • Let Java Beans handle the data
  • Separates programming (Bean) from presentation (JSP)

Worker JSP (^) Beans Business Processing

Request

Response

2) Dispatcher Design

  • A "dispatcher" accepts requests and routes them to the correct place
  • In a dispatcher design, a front-end JSP (or servlet) looks at some portion of the request, and then chooses the correct place to forward it
  • This is more sophisticated than the page-centric:
    • More flexible and scalable
    • More overhead that is wasted with small applications
  • Three versions
    • Mediator-View
    • Mediator-Composite View
    • Service to Workers

11/24/2003 © Dr. Wu and Dr. Offutt 9

2-A) Mediator-View Design

  • The Mediating JSP sends requests to a JSP
  • The JSP sets and gets beans and creates a page

Request Mediating JSP/Servlet Business Processing Response

Presentation JSP

Presentation JSP

Presentation JSP

Worker Beans

Worker Beans Delegate

2-B) Mediator-Composite Design

  • The mediator-view helps with dynamically changing data, but sometimes the structure around the data changes
  • Consider a web site that sells books, CDs, and videos
    • The title, author and price form the data
    • The structure will be different with each type of item
  • With a mediator-view, the JSP has to be changed to introduce new types of products
  • The mediator-composite architecture allows nesting of JSPs and HTML …

11/24/2003 © Dr. Wu and Dr. Offutt 13

2-C) Service to Workers Design

Response

Request

JSP

Mediating JSP

Service

Workers

Java Bean

EJB

Resources

Biz Delegate

2-C) Service to Workers Design (2)

  • The mediator sends requests to "worker beans"
  • The worker beans use the back-end software to populate the beans with data
  • The JSPs then take the data and create output pages
  • This method breaks up the "view" and the "controller"
  • Useful when there many methods are needed to generate the data