title: Browser can't connect to Jetty server
body: <p>I saw another question like this on StackOverflow, but the answers he got were pretty, rediculous. "Connect to the localhost." -- Like, okay. </p>
  
  <p>Anyway, the problem is I finally got my embedded Jetty server to compile and run, the problem was since I'm using it in an API i needed the sources, instead of just the dependency. </p>
  
  <p>I'm running the most basic hello-world code right now, and the server is starting, but none of my browsers can form a connection.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>try {
      httpServer = new Server(8080);
      httpServer.setHandler(new JettyPage());
      httpServer.start();
  } catch(Exception e) {
      e.printStackTrace();
  }
  </code></pre>
  
  <p>Naturally, here's JettyPage.java:</p>
  
  <pre><code>public class JettyPage extends AbstractHandler {
  
      @Override
      public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException {
          response.setContentType("text/html;charset=utf-8");
          response.setStatus(HttpServletResponse.SC_OK);
          baseRequest.setHandled(true);
          response.getWriter().println("&lt;h1&gt;Hello world.&lt;/h1&gt;");
      }
  
  }
  </code></pre>
  
  <p>The output in the console:</p>
  
  <pre><code>2014-11-07 07:01:05.155:INFO::main: Logging initialized @599ms
  2014-11-07 07:01:05.190:INFO:oejs.Server:main: jetty-9.3.0.M1
  2014-11-07 07:01:05.215:INFO:oejs.ServerConnector:main: Started ServerConnector@6e5e91e4{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
  2014-11-07 07:01:05.215:INFO:oejs.Server:main: Started @660ms
  </code></pre>
  
  <p>Firefox:</p>
  
  <pre><code>The connection was reset
  </code></pre>
  
  <p>Opera:</p>
  
  <pre><code>No data received
  </code></pre>
  
  <p>Chrome:</p>
  
  <pre><code>No data received
  </code></pre>
  
  <p>--- Yes, I am connecting to localhost:8080
  I've also tried: 0.0.0.0:8080 and 127.0.0.1:8080</p>
  
  <p><strong>Note:</strong> If I disable my apache server that's running on port 80, and bind Jetty to port 80, I still can't connect.</p>