Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in Sevlet Mapping

 
V Gala
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The correct answer should be C & E in this case.
Thanks
 
John Pearson
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 */*
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic