The web server for the developer in a hurry...

jhttpd is a Java HTTP/1.0 web server with a number of unusual features.

  • Source level compatible with servlet 2.1 container.
  • It is has only 50k of source which is freely available.
  • It recompiles classes automatically when source changes.
  • It can preempt a servlet when a user cancels the load of a page.
  • It can run inside a Web Browser as a "signed" Java Applet.
  • It has a Java version of the popular Perl module CGI.pm
  • It will run Perl CGI scripts and "Perl Server Pages"

    Using these features it is possible to quickly develop web applications under UNIX using the incremental compile feature as you would a scripting language. These applications can then be deployed to a conventional web server or served as a "client-client" applet web application served by its own http server running inside the web browser (as in dbexplorer.com) or even the Eclipse IDE (dbeclipse.org).

    Download
    To use jhttpd under GPL v2 download the distribution here to extract the following:

    jhttpd/jhttpd.sh  # runs the server
    jhttpd/jhttpd.bat # runs the server (your mileage may vary)
    jhttpd/lib        # jar files to include in classpath
    jhttpd/docs       # root for documents served by server
    jhttpd/src        # place for java servlet source
    
    Use jhttpd.sh to start the server and browse to the web address given (port 8089). The default page (index.html) has pointers to example servlet (JGI), CGI and Perl server pages(PSP) as starting points. Servlets are contained in the "src" directory and have the class name as the first component of the URL's path.
  •   The web server requires a full Java jdk (a.k.a SE) to be installed from java.sun.com and the environment variable JAVA_HOME to be set to the place where this is installed. Once this is set up you can develop the server itself incrementally by unziping the contents of lib/jhttpd.jar to place it's source in the "src" directory and then removing the file lib/jhttpd.jar. The web server will then recompile itself each time a request is served apart from a small set of bootstrap and ClassLoader code in org/jhttpd/WebServer.java.

    Advanced Features - Client-Client Architecture

    The server can also be used from inside a web page itself using a "Java Applet". The advantage of this is that the ease of development of web applications can combined with the ease of deployment of an application that requires no server at all.

    To write an embedded web application such as this, the jhttpd.jar needs to be signed and a pair of frames used, one to host the applet while pages are served in the other. An example is this is included in the release. To use an applet use the following HTML:

    <applet name='WebServer' code='org/jhttpd/WebServer.class'
      width=0 height=0 codebase='jars' archive='jhttpd.jar,app.jar'
      style='display: none;' mayscript>
        <param name='onload' value='appletLoaded( "{0}", {1} );'>
        <param name='onerror' value='appletFailed( "{0}" );'>
        <param name='port' value='18089'>
    </applet>
    
    Application servlet code is placed in the file app.jar on the web site and documents & images are also contained in this jar file under a "docs" directory. When the applet has loaded, function appletLoaded( host, port ) is called to load the first page into the other frame and switch to it. If you are still sceptical you can try it now by clicking on this link which will load the web server onto your local machine and display the example servlet included in the release. You will be prompted by Java to load a signed applet.

    Enjoy using jhttpd - we do. If you have any comments or suggestions for enhancements you can send them directly to us at

    If you have used jhttpd and have found it useful you can support the author by donating through paypal by clicking here: