File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Mock Exam Q Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Mock Exam Q" Watch "Mock Exam Q" New topic
Author

Mock Exam Q

Rajesh Krishnan
Greenhorn

Joined: Jul 14, 2005
Posts: 9
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/util/MailServlet.class
B : c:/temp/test/mail/com/jiris/util/MailServlet.class
C : c:/temp/test/mail/util/MailServlet.class
D : c:/temp/test/com/jiris/util/MailServlet.class


The answer given is B.
REason specified is
he full servlet path is construted as follows:

full path = docbase + context path + url-pattern + Resource

Is this correct? Isnt the url-pattern a virtual path?
Mat Williams
Ranch Hand

Joined: Jul 20, 2005
Posts: 215
Hi,

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
c:/temp/test/mail/com/jiris/util/MailServlet.class

if the servlet is in the package "com.jiris.common.util"

HTH

Matt
PNS Subramanian
Ranch Hand

Joined: Jul 13, 2004
Posts: 150
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.
Mat Williams
Ranch Hand

Joined: Jul 20, 2005
Posts: 215
Hi,

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

HTH

Mat
Sergey Tyulkin
Ranch Hand

Joined: May 10, 2005
Posts: 87
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.

Rajesh. can you give me the link to the mock?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Mock Exam Q
 
Similar Threads
some doubts..
Mock Question - Servlet Path
want to ask mock Q
Full Path of Servlet
Mock test doubt