• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

specify a default servlet in DD

 
Aaron Raja
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please explain ?
How would you specify a default servlet in the deployment descriptor? select one choice

[A]
<servlet-mapping>
<servlet-name>MyDefaultServlet</servlet-name>
<url-pattern>*.*</url-pattern>
</servlet-mapping>
[B]
<servlet-mapping>
<servlet-name>MyDefaultServlet</servlet-name>
<url-pattern>*</url-pattern>
</servlet-mapping>
[C]
<servlet-mapping>
<servlet-name>MyDefaultServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
[D]
<servlet-mapping>
<servlet-name>MyDefaultServlet</servlet-name>
<url-pattern>DEFAULT</url-pattern>

Answer should be [B] but Whizlabs say it is [C] and explain as:
A String containing only the '/' character indicates the 'default' servlet of the application. In this case the case the servlet path is the request URI minus the context path and the path info is null.

Any request, which does not have a mapping, will be served by the default servlet.

===========================================================
Thanks
AR
 
Vijitha Kumara
Bartender
Pie
Posts: 3930
21
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aaron Raja wrote:Answer should be B but Whizlabs say it is C and explain as:
A String containing only the '/' character indicates the 'default' servlet of the application. In this case the case the servlet path is the request URI minus the context path and the path info is null.
Any request, which does not have a mapping, will be served by the default servlet.


Explanation is directly taken from servlet spec under SRV.11.2 Specification of Mappings (Servlet 2.4 spec). Hope you got the specs
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic