Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java/Http Question

 
Vernon Gibson
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm opening a socket and sending web pages to a client.
When I send the Html only, the <BACKGROUND> tag is never expanded to display the GIF image.
It seems that I need to send the Images as well as the Html. I've tried using the 'HTTP/1.1 206 Partial Content', in addition to sending both files concatenated as one big response.
Does anyone have an idea of how to get both parts to the browser at the same time?
Thanks
VG
 
maateen ashraf
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
would u plz explain
what type of conection u r using
if u r using URLConnection
then its statless
u have to embade ur commands inside it & u have to filter it on the server side from the query string & send the response..
the other way is to use the socket connection....
let me know is the problem still exists...
 
gautham kasinath
Ranch Hand
Posts: 583
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
Well I guess I had a similar praw.
I was developing a proxy server but then all went well but during the image tag the server started downloading the image it self..
how do I go about dev. a proxy without all these hassles?
Regds
Gautham Kasinath
 
Vernon Gibson
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Thanks for your replies.
Maateen:
I am using a socket (result of ServerSocket.accept()).
Gautham & Maateen:
I have found through experamentation that the browser is sending multiple requests. The first is for the Html document. The subsequent requests are for the embedded document items (jpeg, etc.) This information is in the headers forwarded by the browser.
So the solution was:
1) open the socket
2) read the request
3) identify the resource requested
4) send the resource to the browser
5) close the socket
This logic is in a loop based off the ServerSocket.accept(), so each new request opens a new socket.
By the way RFC2616 says that in Http 1.1 protocol you should keep the socket open, but the ServerSocket.accept() method opens a new socket with each request, so I'm closing them when I process the request.
Thanks,
VG
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic