Server Info
The server for this assignment is the following:
course-server.exdsyslab.net
Each of you has an account on that server. You should be able to SSH to the server.
Please let me know ASAP if you have problems logging into the server.
Deployment
In your home directory, there is a directory named "webapps". Create a directory named "cset4100(hw4" inside the webapps directory. You may want to copy your code from hw3 into the hw4 directory.
Requirements
You will be extending the application from the last assignment to support a web service API for the "Products" of a web application that serves JSON to "3rd party software/applications".
You will need to provide JSON support for both the main product "index" page as well as the individual "product detail" page.
The benefits of the ModelRViewRController paradigm should become readily obvious in this assignment. Specifically, you should only need to
1) create a new JSON "view" (e.g., a JSP page that only displays the JSON representation of the data)
2) Add code to your controller to check which view to display. For this assignment, there will be a URL parameter named "format". When the value of the "format" parameter is "json" display the JSON view, otherwise display the regular HTML JSP view.
The sample servlet code I provided for the last assignment already has some sample code to get you started. You only need to provide a JSP "View" page for the JSON format.
In your JSP, to get access to JSON data add the following. The first line does the import, and the second line creates a Google JSON converter object that you can use to convert Java
Objects into JSON representations < @ page import="com.google.gson.*" >
< Gson gson = new GsonBuilder().setPrettyPrinting().create(); >
Example. If I have an object named "fooObject", then the following JSP code will convert the fooObject to a JSON string representation
< = gson.toJson(fooObject) >