Where to Point Your View -- JSP or XSL, Page 3
Which Option Is Best for Your Project?
With the preceding comparison matrix in mind, let's look at some scenarios that would lead you to choose JSP or XSL for your next project.
From the above discussion, you might see a strong leaning toward using XSL for implementing your view. This hasn't been the industry standard approach, although XSL is an industry standard technology. It's newer than JSP. It's not as optimized yet. But it more naturally fills the responsibilities of the View.
- From an architectural perspective, XSL fills the responsibilities of the View and nothing more. It's pure presentation. With a JSP, there is always the danger of overstepping the boundaries.
- If your application is dealing with XML data, then XSL is the easiest and most straightforward way to parse and transform the XML into other formats.
Let's look at some reasons why you might favor implementing your view in JSP over XSL:
- You have a significant investment in include files, beans, tag libraries, and frameworks to support JSP. Going to XSL might be a big leap because these investments would need to be ported to XSL. In this case, you may stay with JSP, or you may consider some of the following hybrid options.
- Extremely high performance is needed for the application.
It is not always desirable to adopt a pure JSP or a pure XSL solution. Here are a few examples of how both technologies can be used to help render the View:
- A JSP is used to create XML from objects. The XML in turn is rendered into HTML or WML by a XSL stylesheet.
- A JSP uses XSL as a "helper" and includes the output from a stylesheet into the HTML or WML stream it is creating.
- A JSP is used to build a data capture form, but the XML results are displayed using XSL.
- A XSL stylesheet is used as a code generator to dynamically create a JSP.
- A JSP is used as a code generator to generate an XSL stylesheet.
Given that MVC is the way to build a J2EE application, how do you implement the "View" or V in MVC? Many would answer, "Well, a JSP, of course" since this is an industry best practice. However, this isn't the only standards-based approach. XSL is gaining maturity and acceptance and should also be considered for this task.
The definitive source of information about Java Server Pages technology can be found at http://java.sun.com/products/jsp/.
An excellent tutorial and links to other XSL resources can be found at http://www.w3schools.com/xsl/default.asp.
Information on the Java Transformation API for XML can be found at
Check out the following link to study more about MVC:
|Other Articles Written by Jeff Ryan|
About the Author
|Jeff Ryan is an architect for Hartford Financial Services. He has eighteen years of experience in information technology in architecting and developing automated solutions to business problems. He may be reached at email@example.com.|
Page 3 of 3