File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Question on web container Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Question on web container" Watch "Question on web container" New topic

Question on web container

Pankaj Kumarkk
Ranch Hand

Joined: Apr 17, 2011
Posts: 109
I am trying to build understanding about web application. My question is:
How do a url in browser gets translated to a specific resource on the server.

I type:

My web app root (ie MyApp) contains a file named ""
Also I have a servlet mapping also which maps to a servlet.

<servlet-name> TestServlet</servlet-name>

In above scenario:
1. Will I get TestServlet or file
2. How does a web container determines which resource to serve for a request(e.g in this scenario what is logic web server uses)
3. Does the servlet resources gets priority on static resources
Louis Bros
Ranch Hand

Joined: Jun 03, 2011
Posts: 54


You use the Deployment Descriptor for mapping the logical name ( of the servlet to the fully qualified name of the servlet (com.yoursite.YourClass).



In this example the name 'TestServlet' is only used within the web.xml file. It's job is to link the servlet class to the urt-pattern.

Hope that helps

Vijitha Kumara

Joined: Mar 24, 2008
Posts: 3867

Note that the web.xml gets the priority when choosing the resource to be served. And in a case where no matching is found then it falls back to the implicit mappings provided by the container.

[How to ask questions] [Twitter]
I agree. Here's the link:
subject: Question on web container