how can i simulate my pc as http server by writing java code to send the http response by socketstre

Discussion in 'Java' started by mike, Aug 20, 2004.

  1. mike

    mike Guest

    my response as follows...


    ***************************************************
    HTTP/1.1 200 OK
    Date: Fri, 30 Oct 1999 14:39:30 GMT
    Server: Apache/1.3.3 (Unix)
    Cache-Control: max-age=3600, must-revalidate
    Expires: Fri, 30 Oct 1999 15:40:00 GMT
    Last-Modified: Mon, 29 Jun 1999 10:29:15 GMT
    Etag: "3e86-410-3596fbbc"
    Content-Length: 1040
    Content-Type: text/html

    HTML Document

    ****************************************************

    how can i simulate my pc as http server by writing java code to send
    the http response by socketstream to some pc in the internet?!

    thanx
     
    mike, Aug 20, 2004
    #1
    1. Advertisements

  2. Open a ServerSocket to listen for connections on a suitable port,
    usually port 80 but it really doesn't matter. Wait for a connection
    from the client, read the client request. Send the response and
    finally close the connection.

    More or less.

    Refer to rfc2616 (at www.ietf.org) for more details.

    /gordon
     
    Gordon Beaton, Aug 20, 2004
    #2
    1. Advertisements

  3. mike

    Dave Monroe Guest

    How about:

    http://jakarta.apache.org/tomcat/index.html

    That wheel has already been invented.
     
    Dave Monroe, Aug 20, 2004
    #3
  4. mike

    mike Guest

    thanx...anyway...i have 3 machine A,B,C.....
    B is java code executed machine

    A ---B--- C

    i write java code use 2 thread

    thread 1:
    A send request to B,and B forward request to C
    C send response to B , i write java code to get the response ,
    i get the response header and <html>....<\html>
    and tranfer <html>....<\html> to Xhtml file....

    i want to send the response header and Xhtml file to A (client)
    how can i change the response header.....and response properly....
    then let the client browser know the Xhtml content?!....


    now i know maybe i should change the content-length response header


    thanx
     
    mike, Aug 22, 2004
    #4
  5. mike

    mike Guest

    regards:

    I write java code to simulate my machine as a HTTP server,when client

    connect to my HTTP server,my HTTP server replied client a xhtml file.

    I use MS IE browser to test,MS IE test OK to read the xhtml file.

    But when I use nokia 6600 to browse the file,nokia 6600 cannot browse

    the xhtml file.why?.......Is something wrong with my idea?


    any constructive suggestion is welcome


    thank you
     
    mike, Sep 21, 2004
    #5
  6. What error do you get on the Nokia 6600?

    Have you verified the Nokia can recognize and display XHTML files? (try
    files on other servers)

    Have you eliminated network issues as a possible source of your problem? Is
    your server inside a firewall? (e.g. home or company network) In your
    testing, did you run a client program (MS IE) on a remote host, ie. one not
    local to the server? To verify that remote clients can connect to your
    server, login to a remote host and run "telnet xxx 80" where xxx is your
    server host and 80 is the HTTP server port.

    /kmc
     
    Keith M. Corbett, Sep 21, 2004
    #6
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.