Results 1 to 2 of 2
  1. #1
    zardos is offline Member
    Join Date
    Jan 2011
    Posts
    8
    Rep Power
    0

    Default How to serv HTTP/1.1 404 Not Found from socket?

    hello, my app is listening for a http request, when it gets it, what ever it is i want to display a 404 Not Found in the client browser.

    When i tellnet my srver it return "HTTP/1.1 404 Not Found" but if i do it from a browser it just loads for a verry long time.

    Do i need to send more code, or many close the socket after i sen the HTTP/1.1 404 msg? this the the response code.

    Java Code:
    while (true) {
    Socket client = serverSocket.accept();
    	
    DataOutputStream output = new DataOutputStream(client.getOutputStream());
    	                            String line = null;
    	                            //len = strlen("HTTP/1.1 404 Not Found\n");
    	                            line = "HTTP/1.1 404 Not Found\n";
    	                            output.writeBytes(line);
    }
    //Thans

  2. #2
    Join Date
    Feb 2011
    Posts
    2
    Rep Power
    0

    Default

    after output.writeBytes() try flusing the buffer...

    output.flush();

Similar Threads

  1. A4J is not found
    By aali-01 in forum Web Frameworks
    Replies: 0
    Last Post: 02-17-2011, 06:53 AM
  2. Replies: 1
    Last Post: 07-02-2010, 02:18 PM
  3. Replies: 7
    Last Post: 11-11-2009, 09:29 PM
  4. append response to the request from Socket and write to another socket
    By vaibhav_singh_vs@yahoo.co in forum Networking
    Replies: 3
    Last Post: 04-17-2009, 08:02 PM
  5. Http change to HTTP\SSL
    By ballyv24 in forum Advanced Java
    Replies: 0
    Last Post: 05-14-2008, 12:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •