File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Mock Exam Q" Watch "Mock Exam Q" New topic

Mock Exam Q

Rajesh Krishnan

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

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

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


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

The declaration in DD is

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

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


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:
subject: Mock Exam Q
It's not a secret anymore!