★ wanayoo — archive 1999 http://www.webtechniques.com/sourcecode/1999/08/java/2.lstNouvelle recherche | Portail wanayoo

 
| home | current issue | archives | source code | events | demo express | search | editorial calendar | advertising | customer service | author guidelines | jobs | about

S O U R C E   C O D E / 1999 / 08 / java / 2.lst

import HttpServer;
import java.util.*;
import java.io.*;

public class LocalServer extends HttpServer {
    public static void main(String[] args) {
        new LocalServer();
    }

    public String action(String filename, Hashtable vars) {
         String realfile=filename;
         // here we see if there is filename query 
         // variable -- if there is, we assume
         // this is really the "CGI" file
         if (vars.containsKey("Filename")) {
             try {
                 int items=0;
                 FileWriter fw = 
                     new FileWriter((String)vars.get("Filename"),true);
                 vars.remove("Filename");
                 Enumeration e=vars.keys();
                 while (e.hasMoreElements()) {
                     if (items++!=0) fw.write(",");
                     Object k=e.nextElement();
                     fw.write("\""+k+"\"=\"" + vars.get(k) + "\"");
                 }
                 fw.write('\n');
                 fw.close();
             } catch (IOException e) {
                 realfile="error.htm";
             }
         } 
         else
             realfile="/response.htm";
         return realfile;
    }
}


| home | current issue | archives | source code | demo express | events | search | editorial calendar | advertising | customer service | author guidelines | jobs | about




Entire contents copyright 1996-2000 CMP Media Inc.
Read our privacy policy.