JSP pages are associated with resource classes. These JSP pages are resolved by converting the fully-qualified class name of the resource class into a path and appending the last path segment of the request URI path to that path. For example, when a GET is performed on the URI path "/", the path to the JSP page is /com/sun/jersey/samples/bookstore/resources/Bookstore/. For this example, since the last path segment is empty, index.jsp is appended to the path. The request then gets forwarded to the JSP page at that path. Similarly, when a GET is performed on the URI path count, the path to the JSP page is /com/sun/jersey/samples/bookstore/resources/Bookstore/count.jsp.
The JSP variable it is automatically set to the instance of Bookstore so that the index.jsp, or count.jsp, has access to the Bookstore instance as a Java bean.
If a resource class inherits from another resource class, it will automatically inherit the JSP pages from the super class.
A JSP page may also include JSP pages using the inheritance mechanism. For example, the index.jsp page associated with the Book resource class includes a footer.jsp page whose location is specified by the super class, Item.
The mapping of the URI path space is shown in the following table.
URI Path |
Resource Class |
HTTP method |
---|---|---|
/ |
Bookstore |
GET |
/count |
Bookstore |
GET |
/time |
Bookstore |
GET |
/items/{itemid} |
Book, CD |
GET |
/items/{itemid}/tracks/{num} |
Track |
GET |