Module jdk.httpserver


module jdk.httpserver
Defines the JDK-specific HTTP server API.

A basic high-level API for building embedded servers. Both HTTP and HTTPS are supported.

The main components are:

  • the HttpExchange class that describes a request and response pair,
  • the HttpHandler interface to handle incoming requests, plus the HttpHandlers class that provides useful handler implementations,
  • the HttpContext class that maps a URI path to a HttpHandler,
  • the HttpServer class to listen for connections and dispatch requests to handlers,
  • the Filter class that allows pre- and post- processing of requests.

The SimpleFileServer class offers a simple HTTP file server (intended for testing, development and debugging purposes only). A default implementation is provided via the main entry point of the jdk.httpserver module, which can be used on the command line as such:


    Usage: java -m jdk.httpserver [-b bind address] [-p port] [-d directory]
                                  [-o none|info|verbose] [-h to show options]
    Options:
    -b, --bind-address    - Address to bind to. Default: 127.0.0.1 or ::1 (loopback).
                            For all interfaces use "-b 0.0.0.0" or "-b ::".
    -d, --directory       - Directory to serve. Default: current directory.
    -o, --output          - Output format. none|info|verbose. Default: info.
    -p, --port            - Port to listen on. Default: 8000.
    -h, -?, --help        - Print this help message.
 
Module Graph:
Module graph for jdk.httpserverModule graph for jdk.httpserver
Since:
9
  • Packages

    Exports
    Package
    Description
    Provides a simple high-level Http server API, which can be used to build embedded HTTP servers.
    Provides a pluggable service provider interface, which allows the HTTP server implementation to be replaced with other implementations.
  • Services

    Uses
    Type
    Description
    Service provider class for HttpServer.