Sending json response from servlet using gson

Here we want to send json data response from servlet.
Here a link is available in jsp page on link click it is calling /jsonResponse url where JsonResponse’s doGet() method is get called.
To generate json response we are setting response.setContentType("application/json"); that is used to set response as application/json
In servlet student object is created with name gender mobile number and three subjects marks. After creating object we are converting objects to json using gson library.

Project Explorer

1284_expo

index.jsp

JsonResponse.java

Student.java

Subject.java

Address

Result

1284_first

1284_second

Downlaod above program from here