In the previous chapter, we used JSP pages to generate the output that was then sent to the client's browser for rendering. Naturally, we can build the entire application using just JSP pages, but if we did, the application and JSP pages would probably become too complex to manage.
Even though JSP pages are very powerful, they can present a considerable processing overhead. Because Spring MVC fully decouples the view from the logic, the JSP pages should not contain any Java scriptlets. Even if the JSP pages contain no scriptlets, they still need to be compiled—a lengthy operation—and the runtime performance is sometimes not as good as we would like to see. Velocity is a viable alternative; it offers much faster rendering times while not restricting the developer too much.
In this chapter, we are going to explore the Tiles framework, which allows you to organize the output generated by the controllers into separate components that you can assemble together using a master template. This greatly simplifies the visual design of the application, and you can make any changes to the overall layout of the output very quickly and you will need very little space for coding mistakes.
However, there are some cases where HTML output is simply not suitable and we have to use PDF or Excel output to present the data to the user.
To summarize, we are going to cover the following view technologies:
JSP pages: We begin with the most widely used view technology in J2EE applications. Specifically we cover the Spring tag library and show you how to use it in your JSP pages.
Velocity: In this section, you learn how to create and use Velocity to render the model prepared by the controllers. We are also going to cover Spring Velocity macros that work almost exactly like the Spring JSP tags.
XSLT: If you have an existing XML document that represents the data you want to render, you should consider using XSLT views. We explain how to use the XSLT view to render the data easily and efficiently.
PDF and Excel: Expanding on the XSLT views, we show you how to use PDF and Excel views. We explain how to create an Excel and a PDF view using the model data.
Tiles: Finally, this chapter explores how to create a final output that consists of small components that are combined into a final page output. This allows you to create more flexible page layouts.