• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Doubt in Sevlet Mapping

 
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
 
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".
 
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 */*.
 
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 */*
 
    Bookmark Topic Watch Topic
  • New Topic