javax.servletinterfaces. It was designed to be used with JRacer WebDAV server and other examples of Web application. It can not be used as normal HTTP server, because it can not access file itself and the only things it do - manage pool of session threads and redirects requests to servlets.
JHttpServer is optimized to provide the best performance for client application. It supports persistent connections and doesn't break the connection until client will do it itself. Each connection is handled by own thread. When number of active connections exceeds limit for maximal number of threads, JHttpServer delay accepting of new connections and waits until one of the active sessions is terminated and it's thread can be used for new connection.
httpserver.jararchive which is included in distribution. Also the distribution contains servlet.jar package with
jaas.jarwhich can be used to use JAAS with JDK1.3.
If you want to perform build of
httpserver.jar yourself, then
build.xml files. First one
is DOS batch file which performs compilation of source using
compiler. Another one is project file for ANT building tool.
If you have ANT installed and be available through the PATH environment variable,
then just execution of
ant will build the project.
httpserver.jarin classpath. All parameters to the server are passed though the command line using system properties and list of arguments consisting of <servlet-path servlet-class> pairs. Currently JHttpServer recognize the following properties:
|Property name||Property description||Default value|
|Port at which server will listen for clients connections||8080|
|Socket linger time||10|
|Maximal number of threads which server can spawn||64|
|JRacer will dump received queries and send replies||false|
|Authentication type (||anonymous|
|Configuration file with properties||jhttpserver.properties|
|Timeout in milliseconds for waiting request by the server after which session will be closed and thread returned in thread pool||0 (disabled)|
|Enables SSL connections||false|
|Port used by SSL||443|
|Accept or reject unauthenicated users||false|
|File generated by keytool||keystore|
Properties can be also specified in
Servlet configuration properties are taken either from file
.properties", or, if this file doesn't exists, from JHttpServer
Example of running JHttpServer:
java -Dport=80 -DmaxThreads=100 org.garret.httpserver.JHttpServer /webdav webdav.WebdavServlet
Create a new keystore and self-signed certificate with corresponding public/private keys. % keytool -genkey -alias duke -keyalg RSA \ -validity 7 -keystore keystore Enter keystore password: password What is your first and last name? [Unknown]: Duke What is the name of your organizational unit? [Unknown]: Java Software What is the name of your organization? [Unknown]: Sun Microsystems, Inc. What is the name of your City or Locality? [Unknown]: Palo Alto What is the name of your State or Province? [Unknown]: CA What is the two-letter country code for this unit? [Unknown]: US Is CN=Duke, OU=Java Software, O="Sun Microsystems, Inc.", L=Palo Alto, ST=CA, C=US correct? [no]: yes Enter key password forTo enable SSL connections you should specify the following properties to JHttpServer:
(RETURN if same as keystore password): This is the keystore that the server will use.
|Enables SSL connections|
|Port used by SSL (by default 443)|
|By default SSL accept unauthenicated users|
|File generated by keytool|
|Command name||Command description|
|help||output list of accepted commands|
|info||output some information about the current server state|
|exit||shutdown the server|
compile.batfile and run it
StartServer.batscript. If will start JHttpServer on your computer using port 80. If this port is used, please specify alternative port in
StartServer.bat. Then in your browser specify url of your computer - for example
http://localhost. You will see content of the content of root directory (if you have permissions to list it).