http - Java Sun HttpServer not serving data -


Some text should be served on the following localhost: 8080 / Nothing happens, however. It does not trigger any exceptions, makes fine, does not crash, etc. ... But the handler is never called. I'm using mint linux.

  import java.io.IOException; Import java.net.InetAddress; Import java.net.InetSocketAddress; Import com.sun.net.httpserver *; Public Segment MySase {@SuppressWarnings ("Ban") The implementation of the public-class Mehndler HTH Handler {@ Override Public Wide Handle (HTTT Exchange Exchange) throws IOException {System.out.println ("Request Received"); String response = " gt; body> Hello World! & Lt; / body & gt; & lt; / html & gt;"; Exchange. SendResponseHeaders (200, response.length ()); . Exchange.getResponseBody () write (response.getBytes ()); Exchange.close (); }} @SuppressWarnings ("ban") private http server server; @SuppressWarnings ("ban") Public MySource () IOException {server = HttpServer.create (New InetSocketAddress (InetAddress.getLocalHost (), 8080), 100); Server.createContext ("/", New MyHandler ()); Server.setExecutor (zero); } @SuppressWarnings ("ban") Public Zero Start () {server.start (); } Public static zero main (string rule []) {try {System.out.println ("Starting ..."); Maisrvar MS = New MyServer (); Ms.start (); Println ("started."); } Hold (exception e) {e.printStackTrace (); }}}  


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -