Url-pattern just matches what you type in the address bar or what a page uses in an <a href=""></a> tag to the actual servlet doing the work. So B is the most correct answer. I will add that b should read c:/temp/test/mail/com/jiris/common/util/MailServlet.class not
Have a question here - i specify my <url-pattern> as "asdf" and i do not have any such folder in my file system. In this case how do we include <url-pattern> as a part of the full path ?
The full path of the servlet is \webapps\ROOT\WEB-INF\src\com\servlet\TestServlet.java
The declaration in DD is <servlet-mapping> <servlet-name>Test1</servlet-name> <url-pattern>/asdf</url-pattern> </servlet-mapping>
I am not very sure if <url-pattern> would be a part of the full path.
Joined: Jul 20, 2005
your <url-pattern> of "asdf" does not appear in the path to the actual class file at all. the <url-pattern> is used to map (hence the tag <servlet-mapping> what the user types in to the address bar with the name of the servlet that the user is requesting.
given the web.xml fragment above, if the user types in <a href="http://localhost:8080/webapp<b rel="nofollow">/Baz</b>" target="_blank">http://localhost:8080/webapp/Baz the servlet container will map this request to the servlet named Bar and then will see that this is should be processed by the servlet com.servlets.Foo
Thus the url-pattern tag has nothing to do with the full path of the servlet. The servlet will be located in .../webapp/WEB-INF/classes/com/servlets/Foo.class
Matt, I think Rajesh understand the things you said.
The question is: Why the correct answer uses url-pattern to construct the full path to the Servlet?
I wonder, if this mock exam is correct itself .... For example, servlet-name = com.jiris.common.util.MailServlet Note: servlet-name, not servlet-class. So we can make no assumptions about the servlet class itself.