Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

vary vary simple web server - Java Code Bank


vary vary simple web server
compile and run the code and type http://127.0.0.1/ in the web browser.
                /*
*Author : Tharindra Galahena 
*University of Colombo School of Computing
*
*/
 
import java.net.*;

import java.io.*;


public class Server

{    

    public static void main(String[] args ) 

    {

        try {    

            ServerSocket soc = new ServerSocket(80);



            Socket insoc = soc.accept();

            PrintWriter out = new PrintWriter (

                insoc.getOutputStream(), true);



            out.println("<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 " 

                + "transitional//EN'>");

            out.println("<html>");

            out.println("<head>");

            out.println("<title>");

            out.println("A new web page");

            out.println("</title>");

            out.println("</head>");

            out.println("<body>");

            out.println("<h1>");

            out.println("This is a very small web server.");

            out.println("</h1>");

            out.println("</body>");

            out.println("</html>");

            insoc.close();

        }

        catch (Exception e) {} 

     } 

}





            
Comments
Sorry but there are no comments to display