Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
How does a browser request files?
Old 11-17-2009, 12:38 PM How does a browser request files?
lizciz's Avatar
Webmaster Talker

Posts: 744
Name: Mattias Nordahl
Location: Sweden
Trades: 0
I presumed the HTML forum would be best suited for this question.

Right now I'm creating a server/client setup in Java for a school project, and outside of the school work I'm implementing some other things too, just for the fun of it, and to learn. I added a second server class to handle HTTP requests, from a normal browser. The HTTPServer class sends back a html page, which also has some images in it. Now to my question

When the browser gets an <img> tag with a 'src', how does it fetch the image? Do the browser send a new request (for every image) that the server handles seperately or is the image somehow sent together with the first response from the server? I got it working, displaying an image on the page, but I ran two Java server classes at the same time. One for the actual page and one for the image, listening on different ports.

Hmm, I now realized my question is more of a Java question than HTML... Perhaps someone can help any way?

In short. In Java, can I somehow do like this:
Code:
/**
 * println(OutputStream os, String str) is a method for sending strings to
 * the connected client (browser) and jpeg is a byte[] array with the image.
 * write(byte[] b) is used to send bytes via the OutputStream
 */

println(os, "My image: ");
println(os, "<img src=\"");
os.write(jpeg);
println(os, "\">");
Or do I have to do this
Code:
println(os, "My image: ");
println(os, "<img src=\"my_address/get_image\">");
and then interpret the 'get_image' request to respind with an image?
__________________
34343639363436653237373432303635373837303635363337 34323037343638363137343263323036343639363432303739 366637353366
lizciz is online now
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
 
Register now for full access!
Old 11-17-2009, 01:29 PM Re: How does a browser request files?
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Every time there is an IMG, SCRIPT, or CSS document in the form of a LINK, etc, is requested, there is a seperate HTTP request being made. I don't know if this helps or not. I'm sure someone else can answer the Java question, though this isn't the ideal place to ask that part of the question.
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 11-17-2009, 02:35 PM Re: How does a browser request files?
lizciz's Avatar
Webmaster Talker

Posts: 744
Name: Mattias Nordahl
Location: Sweden
Trades: 0
Quote:
Originally Posted by wayfarer07 View Post
Every time there is an IMG, SCRIPT, or CSS document in the form of a LINK, etc, is requested, there is a seperate HTTP request being made. I don't know if this helps or not.
It does, I think got an idea of how to implement it. Cheers!
__________________
34343639363436653237373432303635373837303635363337 34323037343638363137343263323036343639363432303739 366637353366
lizciz is online now
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 11-17-2009, 04:47 PM Re: How does a browser request files?
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Quote:
Every time there is an IMG, SCRIPT, or CSS document in the form of a LINK, etc, is requested, there is a seperate HTTP request being made.
Not anymore...
Just for the sack of completness, I'll add my 2 cents here.

To speed up loading times, today browser implement what is called "pipelining" requests.
If the server supports it, it only open one TCP connection to the server, and requests all the element over this connection.

The idea behind this is that the TCP negotiation can be pretty costly in time, and by pipelining the requests, you spare some time in the connections.

You can find more details in the RFC 2616:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html
__________________
Only a biker knows why a dog sticks his head out the window.

Last edited by tripy; 11-17-2009 at 04:49 PM..
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to How does a browser request files?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.13668 seconds with 12 queries