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

    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";

  2. #2
    Join Date
    Feb 2011
    Rep Power


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


Similar Threads

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

Posting Permissions

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