APIdia Launch Partner
Top Description Packages
OpenJDK 27

Module jdk.httpserver

Requires
java.base
Imports
com.sun.net.httpserver.*

Defines the JDK-specific HTTP server API, and provides the jwebserver tool for running a minimal HTTP server.

The com.sun.net.httpserver package defines a high-level API for building servers that support HTTP and HTTPS. The SimpleFileServer class implements a simple HTTP-only file server intended for testing, development and debugging purposes. A default implementation is provided via the jwebserver tool and the main entry point of the module, which can also be invoked with java -m jdk.httpserver.

The com.sun.net.httpserver.spi package specifies a Service Provider Interface (SPI) for locating HTTP server implementations based on the com.sun.net.httpserver API.

System properties used by the HTTP server API

The following is a list of JDK specific system properties used by the default HTTP server implementation in the JDK. Any properties below that take a numeric value assume the default value if given a string that does not parse as a number.

API Note

The API and SPI in this module are designed and implemented to support a minimal HTTP server and simple HTTP semantics primarily.

Implementation Note

The default implementation of the HTTP server provided in this module is intended for simple usages like local testing, development, and debugging. Accordingly, the design and implementation of the server does not intend to be a full-featured, high performance HTTP server.

Implementation Note

Prior to JDK 26, in the JDK default implementation, the HttpExchange attribute map was shared with the enclosing HttpContext. Since JDK 26, by default, exchange attributes are per-exchange and the context attributes must be accessed by calling getHttpContext().getAttributes().
A new system property, jdk.httpserver.attributes (default value: "") allows to revert this new behavior. Set this property to "context" to restore the pre JDK 26 behavior.

Since
9
Used Services
HttpServerProvider

Package Summary

Modifier and TypePackage and Description
exported package
com.sun.net.httpserver

Provides a simple high-level Http server API, which can be used to build embedded HTTP servers.

exported package
com.sun.net.httpserver.spi

Provides a pluggable service provider interface, which allows the HTTP server implementation to be replaced with other implementations.

internal package
internal package
internal package