File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Sockets and Internet Protocols and the fly likes Java/Http Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Java/Http Question" Watch "Java/Http Question" New topic

Java/Http Question

Vernon Gibson
Ranch Hand

Joined: Dec 01, 2000
Posts: 35
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?
maateen ashraf
Ranch Hand

Joined: Jan 08, 2001
Posts: 122
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

Joined: Dec 01, 2000
Posts: 583
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?
Gautham Kasinath

"In the country of the blind, the one eyed man is the King"
Gautham Kasinath CV at :
Vernon Gibson
Ranch Hand

Joined: Dec 01, 2000
Posts: 35
Hi all,
Thanks for your replies.
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.
I agree. Here's the link:
subject: Java/Http Question
jQuery in Action, 3rd edition