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

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

Methods

log( Object obj ) returns void
Used to log messages to the standard output stream when the server is in debug mode.
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.
run( ) returns void
Used to start the web server. Creates a thread pool and instantiates a socket listener for each specified port/address.