java.lang.Object | ||
↳ | com.sun.net.httpserver.HttpServer | |
↳ | sun.net.httpserver.HttpServerImpl |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Binds a currently unbound HttpServer to the given address and port number.
| |||||||||||
Creates a HttpContext.
| |||||||||||
Creates a HttpContext without initially specifying a handler.
| |||||||||||
returns the address this server is listening on
| |||||||||||
returns this server's Executor object if one was specified with
setExecutor(Executor) , or null if none was
specified. | |||||||||||
Removes the given context from the server.
| |||||||||||
Removes the context identified by the given path from the server.
| |||||||||||
sets this server's
Executor object. | |||||||||||
Starts this server in a new background thread.
| |||||||||||
stops this server by closing the listening socket and disallowing
any new exchanges from being processed.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Binds a currently unbound HttpServer to the given 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.
addr | the address to listen on |
---|---|
backlog | the socket backlog. If this value is less than or equal to zero, then a system default value is used. |
IOException |
---|
Creates a HttpContext. A HttpContext represents a mapping from a
URI path to a exchange handler on this HttpServer. Once created, all requests
received by the server for the path will be handled by calling
the given handler object. The context is identified by the path, and
can later be removed from the server using this with the removeContext(String)
method.
The path specifies the root URI path for this context. The first character of path must be '/'.
The class overview describes how incoming request URIs are mapped to HttpContext instances.
path | the root URI path to associate the context with |
---|---|
handler | the handler to invoke for incoming requests. |
Creates a HttpContext without initially specifying a handler. The handler must later be specified using
setHandler(HttpHandler)
. A HttpContext represents a mapping from a
URI path to an exchange handler on this HttpServer. Once created, and when
the handler has been set, all requests
received by the server for the path will be handled by calling
the handler object. The context is identified by the path, and
can later be removed from the server using this with the removeContext(String)
method.
The path specifies the root URI path for this context. The first character of path must be '/'.
The class overview describes how incoming request URIs are mapped to HttpContext instances.
path | the root URI path to associate the context with |
---|
returns the address this server is listening on
returns this server's Executor object if one was specified with
setExecutor(Executor)
, or null
if none was
specified.
null
if not set.
Removes the given context from the server. Removing a context does not affect exchanges currently being processed but prevents new ones from being accepted.
context | the context to remove |
---|
IllegalArgumentException |
---|
Removes the context identified by the given path from the server. Removing a context does not affect exchanges currently being processed but prevents new ones from being accepted.
path | the path of the handler to remove |
---|
IllegalArgumentException |
---|
sets this server's Executor
object. An
Executor must be established before start()
is called.
All HTTP requests are handled in tasks given to the executor.
If this method is not called (before start()) or if it is
called with a null
Executor, then
a default implementation is used, which uses the thread
which was created by the start()
method.
executor | the Executor to set, or null for default
implementation |
---|
Starts this server in a new background thread. The background thread inherits the priority, thread group and context class loader of the caller.
stops this server by closing the listening socket and disallowing any new exchanges from being processed. The method will then block until all current exchange handlers have completed or else when approximately delay seconds have elapsed (whichever happens sooner). Then, all open TCP connections are closed, the background thread created by start() exits, and the method returns. Once stopped, a HttpServer cannot be re-used.
delay | the maximum time in seconds to wait until exchanges have finished. |
---|