title: How to invoke localhost servlet with URL Connection without specifying full url?
body: <p>I am invoking a local servlet from a jsp, the servlet simply returns a json string:</p>
  
  <pre><code>URL url = new URL("http://myapp.appspot.com/myservlet");
  URLConnection conn = url.openConnection();
  conn.setConnectTimeout(5000);
  InputStream is = conn.getInputStream();
  
  StringWriter writer = new StringWriter();
  IOUtils.copy(is, writer, "UTF-8");
  
  String jsonStr = writer.toString();
  </code></pre>
  
  <p>Can I do this with a relative path so that it works both locally and on the deployed instance?</p>