Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > 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?!

Reply
Thread Tools

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

 
 
mike
Guest
Posts: n/a
 
      08-20-2004
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
 
Reply With Quote
 
 
 
 
Gordon Beaton
Guest
Posts: n/a
 
      08-20-2004
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
 
Reply With Quote
 
 
 
 
Dave Monroe
Guest
Posts: n/a
 
      08-20-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) (mike) wrote in message news:<(E-Mail Removed). com>...
> 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.
 
Reply With Quote
 
mike
Guest
Posts: n/a
 
      08-22-2004
Gordon Beaton <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> 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
 
Reply With Quote
 
mike
Guest
Posts: n/a
 
      09-21-2004
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
 
Reply With Quote
 
Keith M. Corbett
Guest
Posts: n/a
 
      09-21-2004
"mike" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I change the response URL to http://server/page.XLS instead of http://server/page.ASPX ? guillermojco@gmail.com ASP .Net 3 04-26-2007 04:49 AM
return HttpStatusCode.ServiceUnavailable in the context.context.Response.StatusCode (Http response code 503) Flip Rayner ASP .Net 1 01-23-2007 06:35 AM
how can i send parameter with writing code miladhatam@gmail.com ASP .Net 7 11-14-2006 11:23 AM
Writing a Java application to send/receive HTTP Requests davidjdoherty@gmail.com Java 5 12-07-2005 08:00 PM
hardware needed to simulate 500 vusers(HTTP) using grinder HArolD Java 4 04-14-2005 07:44 AM



Advertisments