title: Getting "geometry" from google API result
body: <p>So far with the code I have, I am able to get results as a JsonObject. However, I am trying to get the coordinates of the location based on the postal code that I have entered. How can I retrieve the "lat" and "lng" as Strings/JsonElements? Would really appreciate if you can give me some insight. Thanks! </p>
  
  <pre><code>   protected void processRequest(HttpServletRequest request, HttpServletResponse response)
          throws ServletException, IOException {
      response.setContentType("application/json");
  
      //the JSON builder
      Gson gson = new GsonBuilder().setPrettyPrinting().create();
  
      try (PrintWriter out = response.getWriter()) {
          /* TODO output your page here. You may use following sample code. */
          String restaurant = request.getParameter("r");
          String customer = request.getParameter("c");
  
          //Get coordinates of the restaurant 
          String longLatApi = "https://maps.googleapis.com/maps/api/geocode/json?address=" + restaurant;
          URL url = new URL(longLatApi);
          URLConnection connection = url.openConnection();
          connection.addRequestProperty("Referer", longLatApi);
  
          String line;
          StringBuilder builder = new StringBuilder();
          BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
          while ((line = reader.readLine()) != null) {
              builder.append(line);
          }
  
          String jsonString = builder.toString();
          JsonObject obj = new JsonParser().parse(jsonString).getAsJsonObject();
  
          out.println(gson.toJson(obj));
  </code></pre>