Creating a JSP View

Java Server Pages (JSPs) are a technology used to create dynamically generated web pages based on HTML, XML, or other document types. The standard way to create a view in a JSP application is to have a JSP that takes a Java bean, which is an ordinary Java data class, as an attribute. The JSP then inserts the properties from that bean into the appropriate places in the output HTML.

In this tutorial you now create a JSP view to map the book application.
  1. Expand the JSPBookDemo project, right-click the WebContent node, and click New > JSP File.
  2. Type BookJsp.jsp in the File name field.
  3. Click Finish.
  4. Overwrite the skeleton contents of the file with the BookJsp.jsp file that you downloaded previously.
  5. Click File > Save.


Examine the BookJsp.jsp file, and you will see several variables, which are elements that start with a $ sign and are enclosed in braces, for example ${book.stockno}. The example variable states that the JSP will insert the value contained in the stockno property of the book attribute at this point.

There are also other non-book variables, an example of which is ${rununitid}. These variables are more direct text attributes that are not directly related to a book entry, and are kept separate. In the case of ${rununitid}, the program is demonstrating its use in the title of the display.

Once all the variables have been processed, the JSP becomes a simple HTML page containing a form.