I saw another question like this on StackOverflow, but the answers he got were pretty, rediculous. "Connect to the localhost." -- Like, okay.
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.
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.
Here's the code:
try {
httpServer = new Server(8080);
httpServer.setHandler(new JettyPage());
httpServer.start();
} catch(Exception e) {
e.printStackTrace();
}
Naturally, here's JettyPage.java:
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("<h1>Hello world.</h1>");
}
}
The output in the console:
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
Firefox:
The connection was reset
Opera:
No data received
Chrome:
No data received
--- Yes, I am connecting to localhost:8080 I've also tried: 0.0.0.0:8080 and 127.0.0.1:8080
Note: If I disable my apache server that's running on port 80, and bind Jetty to port 80, I still can't connect.