JSON Web Service (HW4)
SuperClassCSET 4100 Assignment 4 JSON Web Service Overview This assignment will focus on creating Java Servlets that can not only serve HTML to web users, but also provide a web service API serving JSON to applications accessing the site. Read CH. 6 and CH. 7 in the Java servlets and JSP textbook. 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 Model--View--Controller 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...
10 years ago
Purchase the answer to view it

- json_web_service_hw4.txt