Server Class

A lightweight, multi-threaded web server used to process HTTP requests and send responses back to the client. The server requires an implementation of the HttpServlet class. As new requests come in, they are passed to the HttpServlet.processRequest() method which is used to generate a response.

Constructors

Server( int port, int numThreads, HttpServlet servlet )
Server( InetSocketAddress address, int numThreads, HttpServlet servlet )
Server( InetSocketAddress[] addresses, int numThreads, HttpServlet servlet )
Server( java.util.List addresses, int numThreads, HttpServlet servlet )

Properties

Public Methods

setMinTLSVersion( Double tlsVersion ) returns void
By default, the server is configured to support TLS 1.0, 1.1, and 1.2. You can disable older ciphers by specifying a minimum TLS version (e.g. 1.2),
run( ) returns void
Used to start the web server. Creates a thread pool and instantiates a socket listener for each specified port/address.

Static Methods

main( String[] args ) returns void
Entry point for the application. Accepts command line arguments to specify which port to use and the maximum number of concurrent threads.
argsCommand line arguments. Options include:
  • -p to specify which port(s) to run on
  • -debug to specify whether to output debug messages to the standard output stream.
  • -dir to specify a path to a directory where html, js, css, images are found. The server will server content from this directory to web clients.
log( Object obj ) returns void
Used to log messages to the standard output stream when the server is in debug mode.