O'Reilly logo

Java™ Performance and Scalability, Volume 1: Server-Side Programming Techniques by Dov Bulka

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix B. Simple Java Web Server

Server.java

 import java.io.*; import java.net.*; import java.util.*; import UrlCache; import MyGetBytes; import LazyDate; import FileInfo; class Server implements HttpConstants { // Print to stdout protected static void p(String s) { System.out.println(s); } // Print to the log file protected static void log(byte[] b) throws IOException { synchronized (log) { log.write(b, 0, b.length); } } static OutputStream log = null; /* our server's configuration information is stored * in these properties */ protected static Properties props = new Properties(); // Where worker threads stand idle static Vector threads = new Vector(); // The web server's virtual root static File root; // Timeout on client connections static ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required