7. Creating the View for Spring MVC

PROBLEM

In the context of Spring MVC, a view generates the user interface based on model data. There a variety of JAVA-based technologies for implementing views, but Java ServerPages (JSP) are the predominant technology for defining Views. JSPs are designed to be implemented in a manner that is optimized for web designers. An abstraction layer like Skyway Builder must allow for the continued use of JSP pages for implementing views.

SOLUTION

Skyway Builder lets you define your user interface using any view technology, including Java ServerPages (JSP). This allows developers very fine grained control of how the user interface renders in modern web browsers, including desktop and mobile browsers. The UI developer can leverage JSP tag libraries, including Java Standard Tag Library (JSTL).

HOW IT WORKS

Figure 2.10. View (MVC)

View (MVC)

Steps for creating a JSP:

  1. Right click on WebContent folder, and select New-->JSP. This will open the New JavaServer Page Wizard.

  2. From the wizard specify the filename for jsp (i.e. index.jsp) and click the Next button.

  3. Select Skyway JSP File (html) as the template, and click the Finish button.

Note

If a JSP page is specified directly in the WebContent folder, it will be accessible as a web resource and through any defined URL Mappings. A best practice is to put the JSP pages in the WEB-INF folder so that the JSP is only accessible through a URL mapping.

RELATED RECIPES

  1. Mapping URLs to Operations and Views

  2. Hiding the Implementation Technology

  3. Implementing Post/Redirect/Get (PRG) Pattern

  4. Implementing an HTML Form in JSP using standard HTML elements

  5. Implementing an HTML Form in JSP using Spring Form Tag Library

  6. Implementing an HTML Form in JSP using Skyway Tag Library

  7. Using Third-Party Tag Libraries