Servlet mapping defines

Options
- an association between a URL pattern and a servlet
- an association between a URL pattern and a request page
- an association between a URL pattern and a response page
- All of the above


CORRECT ANSWER : an association between a URL pattern and a servlet

Discussion Board
Servlet mapping

Servlet mapping defines an association between a URL and servlet as it also specifies the web container of which java servlet should be invoked for a url given by client.

It provides the mapping url patterns to servlets. When client request then servlet container decides to which application it should forward to. Then context path of url is matched for mapping servlets. For this to happen servlets should be registered with the container of the servlet and it needs to have entries in web deployment descriptor or web.xml which is located in WEB-INF directory of the web application.

Entries to be done in web.xml for servlet-mapping:

<servlet-mapping>
<servlet-name>milk</servlet-name>
<url-pattern>/drink/*</url-pattern>
</servlet-mapping>

Rohit Sharma 11-29-2014 10:28 AM

Write your comments


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)


Advertisement