Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mock Question - Servlet Path

 
Sangita Hota
Greenhorn
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??

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:

<servlet>
<servlet-name>MyMail</servlet-name>
<servlet-class>com.jiris.common.util.MailServlet</servlet-class>
<init-param>
<param-name>smtpServer</param-name>
<param-value>someSmtpServer</param-value>
<description>default smtp server address</description>
</init-param>
</servlet>

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

<servlet-mapping>
<servlet-name>MyMail</servlet-name>
<url-pattern>/mail/*</url-pattern>
</servlet-mapping>
 
Narendra Dhande
Ranch Hand
Posts: 951
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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

c:\temp\test\WEB-INF\classes\com\jiris\common\util\MailServlet.class

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.

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic