my dog learned polymorphism*
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 OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Doubt in Sevlet Mapping" Watch "Doubt in Sevlet Mapping" New topic
Author

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/*


Answer
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
Hi,
The correct answer should be C & E in this case.
Thanks


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: http://aspose.com/file-tools
 
subject: Doubt in Sevlet Mapping