APIdia Launch Partner
Top Description Constructors Methods
com.sun.net.httpserver

public abstract Class HttpsServer

extends HttpServer
Class Inheritance
Known Direct Subclasses
sun.net.httpserver.HttpsServerImpl
Imports
java.io.IOException, java.net.BindException, .InetSocketAddress, java.util.Arrays, .Objects, com.sun.net.httpserver.spi.HttpServerProvider

This class is an extension of HttpServer which provides support for HTTPS.

A HttpsServer must have an associated HttpsConfigurator object which is used to establish the SSL configuration for the SSL connections.

All other configuration is the same as for HttpServer.

Since
1.6

Constructor Summary

AccessConstructor and Description
protected
HttpsServer()

Constructor for subclasses to call.

Method Summary

Modifier and TypeMethod and Description
public static HttpsServer

Returns:

an instance of HttpsServer
create
()

Hides com.sun.net.httpserver.HttpServer.create.

Creates a HttpsServer instance which is initially not bound to any local address/port.

public static HttpsServer

Returns:

an instance of HttpsServer
create
(InetSocketAddress
the address to listen on, if null then bind(InetSocketAddress, int) must be called to set the address
addr
,
int
the socket backlog. If this value is less than or equal to zero, then a system default value is used.
backlog
)

Hides com.sun.net.httpserver.HttpServer.create.

Create a HttpsServer instance which will bind to the specified java.net.InetSocketAddress (IP address and port number).

public static HttpsServer

Returns:

the HttpsServer
create
(InetSocketAddress
the address to listen on, if null then bind must be called to set the address
addr
,
int
the socket backlog. If this value is less than or equal to zero, then a system default value is used
backlog
,
String
the root URI path of the context, must be absolute
path
,
HttpHandler
the HttpHandler for the context
handler
,
Filter...
the Filters for the context, optional
filters
)

Hides com.sun.net.httpserver.HttpServer.create.

Creates an HttpsServer instance with an initial context.

public abstract HttpsConfigurator

Returns:

the HttpsConfigurator for this server, or null if not set
getHttpsConfigurator
()

Gets this server's HttpsConfigurator object, if it has been set.

public abstract void
setHttpsConfigurator(HttpsConfigurator
the HttpsConfigurator to set
config
)

Sets this server's HttpsConfigurator object.

Inherited from com.sun.net.httpserver.HttpServer:
bindcreateContextcreateContextgetAddressgetExecutorremoveContextremoveContextsetExecutorstartstop

Constructor Detail

HttpsServerback to summary
protected HttpsServer()

Constructor for subclasses to call.

Method Detail

createback to summary
public static HttpsServer create() throws IOException

Hides com.sun.net.httpserver.HttpServer.create.

Creates a HttpsServer instance which is initially not bound to any local address/port. The HttpsServer is acquired from the currently installed HttpServerProvider. The server must be bound using bind(InetSocketAddress, int) before it can be used. The server must also have a HttpsConfigurator established with setHttpsConfigurator(HttpsConfigurator).

Returns:HttpsServer

an instance of HttpsServer

Exceptions
IOException:
if an I/O error occurs
createback to summary
public static HttpsServer create(InetSocketAddress addr, int backlog) throws IOException

Hides com.sun.net.httpserver.HttpServer.create.

Create a HttpsServer instance which will bind to the specified java.net.InetSocketAddress (IP address and port number). A maximum backlog can also be specified. This is the maximum number of queued incoming connections to allow on the listening socket. Queued TCP connections exceeding this limit may be rejected by the TCP implementation. The HttpsServer is acquired from the currently installed HttpServerProvider. The server must have a HttpsConfigurator established with setHttpsConfigurator(HttpsConfigurator).

Parameters
addr:InetSocketAddress

the address to listen on, if null then bind(InetSocketAddress, int) must be called to set the address

backlog:int

the socket backlog. If this value is less than or equal to zero, then a system default value is used.

Returns:HttpsServer

an instance of HttpsServer

Exceptions
IOException:
if an I/O error occurs
BindException:
if the server cannot bind to the requested address, or if the server is already bound
createback to summary
public static HttpsServer create(InetSocketAddress addr, int backlog, String path, HttpHandler handler, Filter... filters) throws IOException

Hides com.sun.net.httpserver.HttpServer.create.

Creates an HttpsServer instance with an initial context.

The server is created with an initial context that maps the URI path to the exchange handler. The initial context is created as if by an invocation of createContext(path). The filters, if any, are added to the initial context, in the order they are given. The returned server is not started so can be configured further if required.

The server instance will bind to the given java.net.InetSocketAddress.

A maximum backlog can also be specified. This is the maximum number of queued incoming connections to allow on the listening socket. Queued TCP connections exceeding this limit may be rejected by the TCP implementation. The HttpsServer is acquired from the currently installed HttpServerProvider.

The server must have an HttpsConfigurator established with setHttpsConfigurator(HttpsConfigurator).

Parameters
addr:InetSocketAddress

the address to listen on, if null then bind must be called to set the address

backlog:int

the socket backlog. If this value is less than or equal to zero, then a system default value is used

path:String

the root URI path of the context, must be absolute

handler:HttpHandler

the HttpHandler for the context

filters:Filter[]

the Filters for the context, optional

Returns:HttpsServer

the HttpsServer

Exceptions
IOException:
if an I/O error occurs
BindException:
if the server cannot bind to the address
IllegalArgumentException:
if path is invalid
NullPointerException:
if any of: path, handler, filters, or any element of filters, are null
Since
18
getHttpsConfiguratorback to summary
public abstract HttpsConfigurator getHttpsConfigurator()

Gets this server's HttpsConfigurator object, if it has been set.

Returns:HttpsConfigurator

the HttpsConfigurator for this server, or null if not set

setHttpsConfiguratorback to summary
public abstract void setHttpsConfigurator(HttpsConfigurator config)

Sets this server's HttpsConfigurator object.

Parameters
config:HttpsConfigurator

the HttpsConfigurator to set

Exceptions
NullPointerException:
if config is null