jQuery in Action, 3rd edition
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
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: 110
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: http://testserver.com/MyApp/test.do

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

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

In above scenario:
1. Will I get TestServlet or test.do 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 (test.do) 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: 3902

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: http://aspose.com/file-tools
subject: Question on web container
jQuery in Action, 3rd edition