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. Advertising

  2. On 19 Aug 2004 22:00:06 -0700, mike wrote:
    > 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?!


    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

    --
    [ do not email me copies of your followups ]
    g o r d o n + n e w s @ b a l d e r 1 3 . s e
    Gordon Beaton, Aug 20, 2004
    #2
    1. Advertising

  3. mike

    Dave Monroe Guest

    (mike) wrote in message news:<>...
    > my response as follows...
    >
    > 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?!


    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

    Gordon Beaton <> wrote in message news:<>...
    > On 19 Aug 2004 22:00:06 -0700, mike wrote:
    > > 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?!

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

    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. "mike" <> wrote in message
    news:...
    > 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?


    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. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. HArolD
    Replies:
    4
    Views:
    583
    HArolD
    Apr 14, 2005
  2. Replies:
    5
    Views:
    41,082
    Roedy Green
    Dec 7, 2005
  3. Replies:
    7
    Views:
    370
  4. Replies:
    3
    Views:
    781
    Guillermo
    Apr 26, 2007
  5. Luis Faisco

    How to simulate HTTP POST using headers?

    Luis Faisco, May 8, 2004, in forum: ASP General
    Replies:
    1
    Views:
    170
    Aaron Bertrand [MVP]
    May 9, 2004
Loading...

Share This Page