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 Doubt in Sevlet Mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Doubt in Sevlet Mapping" Watch "Doubt in Sevlet Mapping" New topic

Doubt in Sevlet Mapping

V Gala
Ranch Hand

Joined: Aug 06, 2007
Posts: 113
128 Which are valid URL mappings to a servlet in a web deployment descriptor?
A */*
B /*.do
C /MyServlet
D scwcd/MyServlet
E /MyServlet/*

B, C and E

The servlet mapping must be relative to context root, that means it should start with "/"

Is Option B a valid answer ->For Extension match it must start with a asterik(*) and have a dot extension
John Pearson
Ranch Hand

Joined: Oct 19, 2007
Posts: 51
A servlet mapping of /*.do is not valid for the reasons you mentioned.

Just to see what would happen, I tried it and Tomcat was unable to start the application. It gave the following error: "java.lang.IllegalArgumentException: Invalid <url-pattern> /*.do in servlet mapping".
Khadija Lokhandwala
Ranch Hand

Joined: Sep 11, 2007
Posts: 33
The correct answer should be C & E in this case.

If you ask me anything I don't know, I'm not going to answer.<br />--Yogi Berra
John Pearson
Ranch Hand

Joined: Oct 19, 2007
Posts: 51
Actually, the correct answers should be A, C, and E.

I know a mapping of */* looks like it shouldn't be allowed, but it does work. Because it starts with "*", it's treated as an extension mapping, matching anything with an extension of "*".

For instance, if on your browser you entered "http://localhost:8080/MyTest/Test.*", that would match a mapping of */*.
Ash More'
Ranch Hand

Joined: Apr 20, 2008
Posts: 47
hi John.
how does "http://localhost:8080/MyTest/Test.*" map to */*
i tried it , it doesn't work. *.* works for "http://localhost:8080/MyTest/Test.*" using extension match, but not */*
I agree. Here's the link:
subject: Doubt in Sevlet Mapping
It's not a secret anymore!