Jetty Logo
Version: 9.3.13.v20161014
Contact the core Jetty developers at

private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services for sponsored feature development

Shutdown Handler




A handler that shuts the server down on a valid request. This is used to perform "soft" restarts from Java. If _exitJvm is set to true a hard System.exit() call is being made.

This is an example of how you can setup this handler directly with the Server. It can also be added as a part of handler chain or collection.

    Server server = new Server(8080);
    HandlerList handlers = new HandlerList();
    handlers.setHandlers(new Handler[]
    { someOtherHandler, new ShutdownHandler(server,"secret password") });

This is an example that you can use to call the shutdown handler from within java.

   public static void attemptShutdown(int port, String shutdownCookie) {
        try {
            URL url = new URL("http://localhost:" + port + "/shutdown?token=" + shutdownCookie);
            HttpURLConnection connection = (HttpURLConnection)url.openConnection();
  "Shutting down " + url + ": " + connection.getResponseMessage());
        } catch (SocketException e) {
            logger.debug("Not running");
            // Okay - the server is not running
        } catch (IOException e) {
            throw new RuntimeException(e);

See an error or something missing? Contribute to this documentation at Github!(Generated: 2016-10-14)