Wednesday, June 07, 2006

Simple HTTP Server in Java

Just for fun (well, almost), I wrote my very own simple HTTP server in Java (download 100 KB ZIP) the other night. It uses Java5 features, and requires no external libraries. While it certainly does work and can serve a static website HTML+image site, it is of course NOT meant as a "real" web server, so do NOT use it - it's instructional, and it sure was fun to code!

PS: Almost eight years ago, I put online a Proxy Server written in C on my website, and to my big surprise, during all the years since, every now and then a CS student (presumably asked to write one for class, just like I had at the time), emails some questions... So just in case folks, if you found this page because you are looking for a cheap way out for your homework, by all means download and look at it - but then fix/improve it, and quoting the source and explaining your enhancements! And put a quick comment to this post below.

3 Comments:

Anonymous Anonymous said...

Hey good job! It was really helpful for me. I was looking for a simple single threaded web server.

06 December, 2006 23:23  
Anonymous Anonymous said...

Good this. I wrote my own version to support serving xml data from a DB over http to a flex application. But my C: drive bit the dust and I needed a replacement http server class rather than rewrite my own again.
Thanks for this. Saves me a lot of rework!

Chris

17 January, 2008 14:20  
Blogger Filirom1 said...

5 years later, I found your code and find it very usefull.

I added the dir listing feature and put the library on maven.

Here is the new source code : https://github.com/Filirom1/SimpleHTTPServer

Cheers

Romain

15 April, 2011 11:03  

Post a Comment

Links to this post:

Create a Link

<< Home