title: How can I send user to .html page within servlet if JSON response result is 0/11
body: <p>Let's say user logs onto my site with the correct credentials which results in</p>
  
  <pre><code>{"ticketStatus":"Valid","requestId":"73","result":0,"resultText":"Valid"}
  
  {"ticketStatus":"Invalid","requestId":"8","result":11,"resultText":"Invalid"}
  </code></pre>
  
  <p>How can I make it so that I can retrieve either "valid/invalid" or "0/11" so it sends the user to valid.html/invalid.html(which contains you've succesfully/unsuccesfully logged in). 
  Same goes for if it's "invalid" or "11"(either one, depends on what I can assign). I just don't know how or what I should select in order to put it inside an if statement. Here's my code.</p>
  
  <pre><code>protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  
  
  }
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  
      //index.html form user input
       String fname = request.getParameter("firstName");
      String lastName = request.getParameter("lname");
      String ticketNummer = request.getParameter("ticketnr");
  
      JsonParser parser = new JsonParser();
  
      URL object=new URL(url);
  
      String ticketCheck = "{\"function\":\"Check\",\"teamId\":\"IC106-2\",\"teamKey\":\"1b3741ccf6d9ec5245055370125d901e\",\"requestId\":\""+REQ_ID+"\",\"firstName\":\""+fname+"\",\"lastName\":\""+lastName+"\",\"ticketNumber\":\""+ticketNummer+"\"}";
  
      System.out.println(ticketCheck);
  
      HttpURLConnection con = (HttpURLConnection) object.openConnection();
      con.setDoOutput(true);
      con.setDoInput(true);
      con.setRequestProperty("Content-Type", "application/json");
      con.setRequestProperty("Accept", "application/json");
      con.setRequestMethod("POST");
  
      OutputStreamWriter writer = new OutputStreamWriter(con.getOutputStream());
      writer.write(ticketCheck);
      writer.flush();
  
      StringBuilder sb = new StringBuilder();
      String jsonResponseString = sb.toString();
      JsonElement jsonTree = parser.parse(jsonResponseString);
  
      int HttpResult = con.getResponseCode();
      if (HttpResult == HttpURLConnection.HTTP_OK) {
          BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream(), "utf-8"));
          String line;
          while ((line = br.readLine()) != null) {
              sb.append(line + "\n");
          }
          br.close();
          System.out.println("" + sb.toString());
      } else {
          System.out.println(con.getResponseMessage());
      }
  
  
  
  
  
  
  
  }
  </code></pre>