1.0 updates:
  1. none
Elliott MyWebServer Tips
Disclaimer: try these. No guarantees.

Getting root directory:


(Thanks Boma)

import java.io.*;

public class ShowDir {
  public static void main(String[] args) {
    File f = new File(".");
    try{
      String directoryRoot = f.getCanonicalPath();
      System.out.print("Directory root is: " + directoryRoot);
    }catch (Throwable e){e.printStackTrace();}
  }
}

Firefox addin for viewing HTTP headers:

https://addons.mozilla.org/en-US/firefox/addon/60

Writing http headers:

Note: your browser may work differently. You WILL have to play with this! These snippets (that is, only part of the code) are just some suggestions for getting started. For debugging, use a separate stream and also write a duplicate of everything to your system console, or a file, identically to what you are writing to the socket. Post to newsgroup if you have questions, suggestions, updates.

   (Thanks Eric)

   private PrintStream	out = null;
   [...]
   out.append("HTTP/1.1 200 OK\n");
   out.append("Date: " + new Date() + "\n");
   out.append("\n\n");
   etc.
and:

  (Thanks John)

  static final byte[] EOL = {(byte) '\r', (byte) '\n'};

  OutputStream out = new BufferedOutputStream(sock.getOutputStream());
  PrintWriter prntout = new PrintWriter(new OutputStreamWriter(out), true);


  prntout.println("HTTP/1.1 200 OK");
  prntout.println("Content-Length: " + thedata.length());

  prntout.println("Content-type: " + ct);
  out.write(EOL);
and:
  (Thanks Kevin)

   private String outputData = 
  "HTTP/1.1 200 OK" + "\r\n" +
  "Content-Length: " + "LENGTH" + "\r\n" +
  "Connection: CONNECTION" + "\r\n" +
  "DATATYPE" + "\r\n\r\n";

  [Use stringval.replace(x.y) substitution for values determined at runtime]