• Post Reply Bookmark Topic Watch Topic
  • New Topic

Image downloads by browser  RSS feed

 
Abhinav Srivastava
Ranch Hand
Posts: 354
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I have understood, first the skeleton HTML content is downloaded and then the browser asks the server for Images etc by sending request(s). But our requests are handled by a servlet. So how does the server know that it has to serve a file rather than looking into web.xml for further forwards.
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If this example is not your situation, you'll have to provide more details, but here is one explanation...

The page you request is:

http://www.mysite.com/servlet/catalog?page=5

First, whatever process (probably a webserver) is listening to port 80 on the www.mysite.com will look at /servlet/catalog?page=5

It sees /servlet and says "aha, I must forward that to my Tomcat instance" (or Weblogic or iplanet... whatever). When it gets there, Tomcat will says "I have a /catalog mapped to this class over here, I will send it the parameter 'page=5' and the response will be sent back to the webserver. The webserver then sends that response back to the browser.

If you are running standalone Tomcat, then Tomcat is the one to say "aha, I see /servlet and that means I am to respond with the output of the servlet mapped to /catalog after sending it 'page=5'.

When your browser gets the response, it parses the response and for every image, it will make a new request.

What saves you from going through Tomcat again and again, is that the image is usually requested from an images directory. The request would be for something very much like:

http://www.mysite.com/images/foo.gif

So the webserver gets this, and there is no /servlet in the request URI. Therefore, it will merely server the static foo.gif from the images directory.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!