title: Parse JSON file into Java Object which is redirected to JSP page
body: <p>This is my first time using JSON and I would appreciate some help. I have searched for an answer for a couple of days without finding a solution that helps me to get forward. I'm doing a Java Web Application which has these components:</p>
  
  <ol>
  <li>Servlet, which recieves a GET call </li>
  <li>In GET you read a JSON file which contains student data (name, lastname, studentid, courses, course grades)</li>
  <li>Data must be converted in to Java object </li>
  <li>Data will be redirected to a JSP page </li>
  <li>JSP page will display a HTML page, where the data is rendered into a HTML table</li>
  </ol>
  
  <p>I know this is a wonky way to do this, but I only know Java and therefore doing my task this way. Here is my JSON file, Servlet and JSP page. I also have all the POJOs required.</p>
  
  <p>JSONData.json</p>
  
  <pre><code>{  "students": [
  {
    "student": {
      "name": "Mike",
      "lastname": "Merrit",
      "studentid": 10,
      "course1": {
        "coursename": "Programming",
        "grade": 5
      },
      "course2": {
        "coursename": "Project",
        "grade": 3
      },
      "course3": {
        "coursename": "Java EE",
        "grade": 4
      },
      "startyear": 2015
    }
  },
  {
    "student": {
      "name": "Peter",
      "lastname": "Lombok",
      "studentid": 20,
      "course1": {
        "coursename": "Business",
        "grade": 4
      },
      "course2": {
        "coursename": "Math",
        "grade": 5
      },
      "course3": {
        "coursename": "Law",
        "grade": 2
      },
      "startyear": 2014
    }
  },
  {
    "student": {
      "name": "Rick",
      "lastname": "Roberts",
      "studentid": 30,
      "course1": {
        "coursename": "Databases",
        "grade": 3
      },
      "course2": {
        "coursename": "Linux",
        "grade": 3
      },
      "course3": {
        "coursename": "Windows",
        "grade": 5
      },
      "startyear": 2016
    }
  }]}
  </code></pre>
  
  <p>GetServlet.java</p>
  
  <pre><code>public class GetServlet extends HttpServlet {
  
  @SuppressWarnings("unchecked")
  public void doGET(HttpServletRequest request, HttpServletResponse response)
          throws IOException, ServletException {
      response.setContentType("text/html;charset=UTF-8");
  
      // JSONParser parser = new JSONParser();
      // ObjectMapper mapper = new ObjectMapper();
      Gson gson = new Gson();
      BufferedReader reader = null;
  
      try {
          reader = new BufferedReader(new FileReader("JSONData.json"));
          StudentList studentsList = gson.fromJson(reader, StudentList.class);
  
          request.setAttribute("students", studentsList);
          request.getRequestDispatcher("students.jsp").forward(request,
                  response);
  
      } catch (Exception ex) {
          ex.printStackTrace();
      }
  
  }}
  </code></pre>
  
  <p>students.jsp</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=UTF-8"
  pageEncoding="UTF-8"%&gt;
  &lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%&gt;
  &lt;%@page import="java.util.ArrayList"%&gt;
  &lt;%@page import="java.util.List"%&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Students&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form action="/students" method="GET"&gt;
  
      &lt;table&gt;
          &lt;c:forEach items="${studentsList}" var="student"&gt;
              &lt;tr&gt;
                  &lt;c:out value="${student.name}"/&gt;
  
              &lt;/tr&gt;
          &lt;/c:forEach&gt;
      &lt;/table&gt;
  
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I'm currently confused if JSON file is correctly parsed into Java Object, if not what is it that I'm doing wrong here? I have looked into JSON.Simple, GSON and Jackson without finding an answer that solves my problem.</p>
  
  <p>Also am I correctly sending the data to JSP, because at the moment it's not printing anything? I have done a bit of JSTL coding, but only with SQL databases and POST method.</p>
  
  <p>Thanks for your help!</p>