@@ -0,0 +1,2511 @@
+import java.io.*;%0Aimport java.net.*;%0A%0Apublic class Server %7B%0A%0A    public static String getPath(String line) %7B%0A        String path = %22%22;%0A        String a = line.substring(4);%0A        int index = a.indexOf(%22 HTTP/%22);%0A        path = a.substring(0, index);%0A        return path;%0A    %7D%0A%0A    public static void main(String args%5B%5D) throws IOException %7B%0A        int port = 8899;%0A        ServerSocket server = new ServerSocket(port);%0A        System.out.println(%22server listen...%22);%0A%0A        while (true) %7B%0A%0A            Socket socket = server.accept();%0A            System.out.println(%22connection comming%22);%0A            Reader reader = new InputStreamReader(socket.getInputStream());%0A%0A            System.out.println(%22start to read%22);%0A%0A            BufferedReader is = new BufferedReader(new InputStreamReader(socket.getInputStream()));%0A            PrintWriter os = new PrintWriter(socket.getOutputStream());%0A            BufferedReader sin = new BufferedReader(new InputStreamReader(System.in));%0A%0A            String line = is.readLine();%0A            String path = Server.getPath(line);%0A%0A            System.out.println(%22Client request path:%22 + path);%0A%0A            String html = %22%22;%0A%0A            if (path.equals(%22/%22)) %7B%0A                html = %22%3Ch1%3EWelcome to my home page!%3C/h1%3E%22;%0A            %7D else if (path.equals(%22/shutdown%22)) %7B%0A                html = %22%3Ch1%3EWelcome to shutdown my computer!%3C/h1%3E%22;%0A                Process p = Runtime.getRuntime().exec(%22shutdown -s -t 120%22);%0A            %7D else if (path.equals(%22/noshutdown%22)) %7B%0A                html = %22%3Ch1%3EDon%5C't shutdown my computer!%3C/h1%3E%22;%0A                Process p = Runtime.getRuntime().exec(%22shutdown -a%22);%0A            %7D%0A%0A            String headers = %22HTTP/1.1 200 OK%5Cr%5Cn%22 +%0A                             %22Date: Sun, 25 Jan 2015 12:46:58 GMT%5Cr%5Cn%22 +%0A                             %22Server: Timocat/2.2.22 (Win64) Java/8%5Cr%5Cn%22 +%0A                             %22X-Powered-By: Java/8%5Cr%5Cn%22 +%0A                             %22Content-Length: %22 + html.length() + %22%5Cr%5Cn%22 +%0A                             %22Keep-Alive: timeout=5, max=99%5Cr%5Cn%22 +%0A                             %22Connection: Keep-Alive%5Cr%5Cn%22 +%0A                             %22Content-Type: text/html; charset=utf-8%5Cr%5Cn%5Cr%5Cn%22;%0A%0A            String data = headers + html;%0A%0A            if (false) %7B%0A                break;%0A            %7D%0A%0A            os.println(data);%0A            os.flush();%0A%0A            reader.close();%0A            socket.close();%0A            is.close();%0A            sin.close();%0A        %7D%0A%0A        server.close();%0A    %7D%0A%7D%0A

add server