Java Personal Webserver 0.9 Readme
Copyright 1997 Clay Lenhart
lenhart@mindspring.com

Quick Start:
1) Install the Java Runtime Environment (JRE) version 1.1 or higher.  
   Check java.sun.com for an JRE for your operating system.
2) unzip Webserver.zip
3) edit Webserver.prf (a preference file) with a text editor and 
   change rootDir=c:\clay\Webserver to your own directory.
4) run Webserver.class  This is done different ways for different
   operating systems.  At the Windows NT command prompt type 
   java Webserver   (Notice the capital W)


This program is covered under the GNU General Public Licence.  
Basically you may copy the program, change the source code, even
charge others for it, but this licence would apply to them and you
must supply them with the source code.  Lookup the GNU General 
Public Licence for exact details at 
http://www.fsf.org/copyleft/gpl.html
Personally, I distribute Java Personal Webserver 0.9 free of charge, 
and encourage others to do the same.

The files included:
readme.txt
ConnectionAcceptor.class   - Accepts a connection and spawns a connection Thread
ConnectionManager.class    - Very little right now
ConnectionThread.class     - Sends the file or response to client
MainFrame.class            - The user interface
Preferences.class          - Loads the preferences
Webserver.class            - Starts MainFrame and ConnectionAcceptor
Webserver.mim              - The mime types the server can send
Webserver.prf              - The preferences that Preferences.class reads
And the source code:
Webserver.java



This has been a small project I worked on for several months.  I used
to work as a web master for www.davidson.edu and www.med.davidson.edu.  
Soon after leaving, I learned Java and realized how easy it was
to write client/server applications.  I wrote a web server application 
to show how easy it was to write in Java and to encourage others to 
learn Java.  If you have any C++ background, Java will be a piece of 
cake, especially for networking.



                     Webserver.mim
This file is a text file and holds the mime types for certain 
extensions.  If any extensions are missing (and many are) feel free to 
add them.  It is organized by line.  The mime type is first and then 
the extension is second.  Place any number of "white spaces" between 
the two.  White spaces include tabs and spaces.  Please open the file 
to edit it, but don't erase the first line.  And lastly, any text 
after "%end%" is ignored.



                    Webserver.prf
This is also a text file.  You've already edited this file to setup
your root directory.  

rootDir=    - is the directory where the webserver looks for files to
              serve.
index=      - is the file to look for when the client asks for a
              directory.  For instance if index=thisFile.html, then
              http://your.domain.com/ will be indentical to 
              http://your.domain.com/thisFile.html 
Again, any text after "%end%" is ignored.



                      Security 
It is impossible to serve a file outside of the webserver root 
directory.  Even if you put an alias or a link in the root directory 
to a file outside the root directory, the webserver determines where
the file actually is stored and determines if the file is stored 
within the root directory.



               Expanding this Program
Feel free to add to this program.  I plan to make some changes to it 
in the near future.  For instance, saving preferences and mime types,
logging connections, adding CGI's using Java Beans, adding a 
connection status frame with each ConnectionThread currently running, 
and adding security options.



Basic HTTP server operation (for those that are interested):

The client makes a connection on port 80 of the server.  Port 80 is
the HTTP port.  Port 23 is the telnet port and 21 is the FTP port.  
The HTTP client sends something like 

GET /news.html HTTP/1.0

Usually there are more lines after the GET command.  Since I only
implemented the HTTP/0.9 standard, I ignore them.  You know when the
client is done when he sends two returns in a row:  CR LF CR LF 


and then the server responds with something like:

HTTP/0.9 200 OK
Server: Java Personal Webserver 0.9 
MIME-Version: 1.0
Content-type: text/html

<html>                           --|
<h1>The news</h1>                  |- the file: news.html
</html>                          --|


Experiment.  Use your favorite telnet application and connection to 
www.yahoo.com on port 80, and then type 
GET /index.html<return><return>
You should see a html document with some "stuff" at the top.  Telnet 
was a great help while debugging this application.

