protected void service(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {

    PrintWriter out = resp.getWriter();

    String json = req.getParameter("json");
    String key = req.getParameter("key");

    String retval = new String();
    DBProc dbProc = new DBProc();

    ProfileProperties prop = dbProc.verifyProfileKey(key);

    if (prop == null) {
      out.print("Profile Key " + key + " was not Verified");
      out.flush();
      out.close();
      return;
    }

    if (!prop.ispEnabled()) {
      out.print("Profile Key " + key + " is not Enabled");
      out.flush();
      out.close();
      return;
    }

    if (!prop.isPgr_sp()) {
      out.print("ShortestPath Searches for this Profile is not enabled");
      out.flush();
      out.close();
      return;
    }

    if (!prop.ispPublic()) {
      if (!HostInfo.checkHostInfo(req.getRemoteHost(), prop.getHosts())) {
        if (!HostInfo.checkHostInfo(req.getRemoteAddr(), prop.getHosts())) {
          out.print("Not authorized to use this Service[ " + req.getRemoteAddr() + " ]");
          out.flush();
          out.close();
          return;
        }
      }
    }

    if (json == null) {
      out.print("No JSON Request Parameter");
      out.flush();
      out.close();
      return;
    }

    try {
      JSONObject jo = new JSONObject(json);
      String proj = jo.getString("projection");
      String source = jo.getJSONArray("points").getString(0);
      String target = jo.getJSONArray("points").getString(1);

      int epsg = Integer.parseInt(proj.split(":")[1]);

      if (epsg != RouteProperties.getSrid()) {
        source = dbProc.transformPoint(source, epsg);
        target = dbProc.transformPoint(target, epsg);
      }

      retval = dbProc.findShortestPath(prop.getId(), source, target, prop.isReverse_cost());
    } catch (Exception ex) {
      retval = "Error has occured";
      ex.printStackTrace();
    }

    resp.setContentType("application/json");

    out.print(retval);
    out.flush();
    out.close();
  }