![]() |
![]()
| ![]() |
![]()
NAMEjwebserver - launch the Java Simple Web Server SYNOPSISjwebserver [options]
DESCRIPTIONThe jwebserver tool provides a minimal HTTP server, designed to be used for prototyping, testing, and debugging. It serves a single directory hierarchy, and only serves static files. Only HTTP/1.1 is supported; HTTP/2 and HTTPS are not supported. Only idempotent HEAD and GET requests are served. Any other requests receive a 501 - Not Implemented or a 405 - Not Allowed response. GET requests are mapped to the directory being served, as follows:
MIME types are configured automatically, using the built-in table. For example, .html files are served as text/html and .java files are served as text/plain. jwebserver is located in the jdk.httpserver module, and can alternatively be started with java -m jdk.httpserver. It is based on the web server implementation in the com.sun.net.httpserver package. The com.sun.net.httpserver.SimpleFileServer class provides a programmatic way to retrieve the server and its components for reuse and extension. USAGE
OPTIONS
To stop the server, press Ctrl + C. STARTING THE SERVERThe following command starts the Simple Web Server:
If startup is successful, the server prints a message to System.out listing the local address and the absolute path of the directory being served. For example:
CONFIGURATIONBy default, the server runs in the foreground and binds to the loopback address and port 8000. This can be changed with the -b and -p options. For example, to bind the Simple Web Server to all interfaces, use:
Note that this makes the web server accessible to all hosts on the network. Do not do this unless you are sure the server cannot leak any sensitive information. As another example, use the following command to run on port 9000:
By default, the files of the current directory are served. A different directory can be specified with the -d option. By default, every request is logged on the console. The output looks like this:
Logging output can be changed with the -o option. The default setting is info. The verbose setting additionally includes the request and response headers as well as the absolute path of the requested resource. STOPPING THE SERVEROnce started successfully, the server runs until it is stopped. On Unix platforms, the server can be stopped by sending it a SIGINT signal (Ctrl+C in a terminal window). HELP OPTIONThe -h option displays a help message describing the usage and the options of the jwebserver.
|