aspose file tools*
The moose likes Servlets and the fly likes General Query about Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "General Query about Servlet" Watch "General Query about Servlet" New topic
Author

General Query about Servlet

MaheshS Kumbhar
Ranch Hand

Joined: Sep 24, 2009
Posts: 188
I am new learner of Servlets and JSP.
I have one query.

If a client request comes in for static content say html page, then does web server application like apache directly fetches the static content without handing request to web container like tomcat?
Because till now what I learned is that if a request is for servlet then the request is handed over to container(tomcat)
Let me know if I am correct or wrong.

Thanks in advance.


I am slow but sure
Hany Shafik
Ranch Hand

Joined: Jun 21, 2008
Posts: 80
I guess your understanding is correct, In case Tomcat doesn't run in standalone mode. The web server will process HTML files that are stored in the file system and Servlet requests are passed to the Web container.
MaheshS Kumbhar
Ranch Hand

Joined: Sep 24, 2009
Posts: 188
Hany
To be very honest, I didn't get your explaination for my query.
Can you please re-elaborate?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41818
    
  62
You need to understand that Tomcat is both a web server and a servlet container. The web server part is perfectly capable of serving static content like HTML and images. (This is what Hany calles "standalone mode".) Sometimes that part is handled by a dedicated web server (like Apache httpd), though, in which case Tomcat is used only for its servlet container functionality.


Ping & DNS - my free Android networking tools app
Hany Shafik
Ranch Hand

Joined: Jun 21, 2008
Posts: 80
Not sure, but I think there are different modes in which you can run Tomcat.
You can run it in stand alone mode in such case the Servlet container is also a web server and handles both requests HTML pages and Servlet requests.
You can also run tomcat as a add-on to an existing web server (e.g. Apache), in this case only if the request is a Servlet request, the Servlet container will take control.
MaheshS Kumbhar
Ranch Hand

Joined: Sep 24, 2009
Posts: 188
One more question to this.

As per the discussion above, static content request are handled by web server application like apache, but how does it(apache) map the URL to the actual static resource, because mapping URL to resource is done by the container. So is it that web server application also has the same capability to map URL's to resource as container does?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41818
    
  62
Yes.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: General Query about Servlet