This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Java/Http Question" Watch "Java/Http Question" New topic
Author

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?
Thanks
VG
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
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


"In the country of the blind, the one eyed man is the King"
Gautham Kasinath CV at : http://www.geocities.com/gkasinath
Vernon Gibson
Ranch Hand

Joined: Dec 01, 2000
Posts: 35
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java/Http Question
 
Similar Threads
can server send picture in 'ajax' interaction
REST vs HTML
send mail
JavaMail to send HTML based emails
How to send