September 28, 2016
Hot Topics:

Where to Point Your View -- JSP or XSL

  • July 3, 2002
  • By Jeff Ryan
  • Send Email »
  • More Articles »


The MVC (Model View Controller) pattern is a common approach for architecting the presentation tier of your Web application. This article explores options for implementing the view or "V" in MVC. JSP (Java Server Pages) and XSL (eXtensible Stylesheet Language) alternatives will be considered. Both of these approaches are based upon industry standards and are supported by open source implementations.

In our exploration of how to implement the view, we'll cover the following topics:

  • A Review of MVC
  • The JSP Approach
  • The XSL Approach
  • Commonalities
  • Differences
  • Comparison Matrix
  • Which Option Is Best for Your Next Project?
  • Summary

The article assumes a basic understanding of JSP and XSL technology. There are additional resources at the end for further detail about Java Server Pages, eXtensible Stylesheet Language, and the Model View Controller pattern.

A Review of MVC

The MVC architecture decouples the code to handle user actions (Controller), the data and business logic (Model), and the presentation (View). Let's look at a typical transaction to better understand the responsibilities of the Controller, Model, and View objects. Then we'll be better positioned to see how those responsibilities can be implemented when a JSP or XSL view is used.

A client initiates a request, say, for example, to view his bank account balance. The controller object receives this request, and instantiates a model object. The model object accesses a persistent store such as a relational database to retrieve the bank account. Next, the controller asks the view object to display the model and return it back to the client.

The JSP Approach

When the view is implemented as a Java Server Page, the controller object, often but not always a servlet, forwards processing of the request and the response to a JSP view. Prior to this, the controller will add a reference to the model object to the user's session or request object. The JSP will get a handle on the model object, and then will construct the HTML or WML markup to be returned to the client.

The XSL Approach

When the view is implemented in XSL, the basic flow of the transaction remains the same. However, the model now needs to be represented in XML format. Once the model has been built, the controller asks a stylesheet to transform the XML into the desired HTML or WML output.

Note that an XSL view could be implemented on the client rather than the server. In this case, the controller would return the XML to the client where it would be rendered by the XSL stylesheet. However, varying browser support for XSL makes this a bit risky at this point in time.

Page 1 of 3

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel