Jetty-servlet-url und port

Was ist die Methode aufrufen, um herauszufinden, was ist die url und den port ein jetty-servlet ausgeführt wird? So, dass ich nur drucken Sie es auf dem Bildschirm, und verwenden Sie es in der client eine Verbindung herstellen:

url = new URL("trying to figure this out");

Ich bin sowohl der client und der server lokal, in eclipse ist dies ein Schulprojekt.

Relevante code:

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;

public class ServerMain {

    public static void main(String[] args){
        Server server = new Server();
        ServletContextHandler context = 
                new ServletContextHandler(ServletContextHandler.SESSIONS);
        context.setContextPath("Servlet");

        context.setResourceBase("etc/docroot");

        server.setHandler(context);
        context.addServlet(new ServletHolder(new MyServer()), "/game");
        DefaultServlet staticFileServlet = new DefaultServlet();
        context.addServlet(new ServletHolder(staticFileServlet), "/*");
        System.out.println("context: " +  context.getContextPath());
        //System.out.println("One valid Port = "
                  + context.getServer().getConnectors()[0].getPort());
        try {
            server.start();
            server.join();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
InformationsquelleAutor Trup | 2012-08-17
Schreibe einen Kommentar