Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Mock Question - Servlet Path  RSS feed

Sangita Hota
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Based on the following information, please construct the full path for the servlet.

Please select one correct answer.

docbase = c:/temp/
context path = /test
alias name = MyMail
servlet-name = com.jiris.common.util.MailServlet
url-pattern = /mail/*

A : c:/temp/mail/com/jiris/common/util/MailServlet.class
B : c:/temp/test/com/jiris/common/util/MailServlet.class
C : c:/temp/mail/test/com/jiris/common/util/MailServlet.class
D : c:/temp/test/mail/com/jiris/common/util/MailServlet.class

I think answer should be "D", but answer is given as "B" and followed by this explanation??


The full servlet path is construted as follows:
full path = docbase + context path + url-pattern + Resource

Accordingly, if I want to enable the user to access this servlet, I should complete the following step:

1. Define the servlet in the web.xml file:

<description>default smtp server address</description>

2. Define the servlet-mapping in the web.xml file:

Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

According to me , the physical path to the servlet should be :


Here c:\temp is the document root base. So from the path it assumed the path for the Window base directory structure. So the slash should be \ not /.

The physical servlet path

docBase+contextPath+\WEB-INF\classes+directory structure as per package+resource.

All the classes reside in WEB-INF\classes directory if not packaged in JARs.

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!