Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Valid DD

 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I would like to know how
/*.do and /MyServlet/* are valid DD?

Thanks in advance.
 
amit gupta
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes.. they are valid entries for <url-pattern>
 
dhwani mathur
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi sumit

Can you please ellaborate and
explain on the above since i am too
confused
:roll: on the entries in <url-pattern>
as per i know entries for servlet must start
with "/" and not with "* ".......am not sure on this
as well?do let me know if i am right or not?


Thanking you in advance........

SCJP(1.5),SCWCD (preparing...)
Dhwani:>Winning is not important but it is the only
thing.
 
Ashok Kumar Babu
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are three types of <url-pattern> entries.

as
1. Exact Match
2. Directory Match
3. Extension Match



belongs to the third category, does not need a forwarding slash.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"/*.do" is valid, but it probably won't do what you think it does. Namely, it won't do a wildcard match (like "/foo.do" and "/bar.do"), but do an exact match of the URL "/*.do".

At least that's how I read the servlet specification chapter 11.2 - Specification of Mappings.
 
dhwani mathur
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Thanks Ashok for the info i am clear with
extension match but now i doubt on the below

Ulf Dittmer :
"/*.do" is valid, but it probably won't do what you think it does. Namely, it won't do a wildcard match (like "/foo.do" and "/bar.do"), but do an exact match of the URL "/*.do".






you have said it probably wont do wildcard match like /foo.do
but do an exact match ............

now please can you explain please

how an exact match? by using /*.do

with an example please........

since we are using wildcard character * and
still an exact match?i mean then which servlet will be
invoked foo.do or bar.do?

Thanking you in advance.
SCJP(1.5),SCWCD(Preparing....)
Dhwani:>Winning is not important but it is the only thing.
 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

What does /*.do and /MyServlet/* perform?
 
Ashok Kumar Babu
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please refer page no 586 in HFSJ Book. It would be easy to get the whole picture in that single page.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how an exact match? by using /*.do

since we are using wildcard character * and still an exact match?i mean then which servlet will be invoked foo.do or bar.do?

If you read the section of the servlet specification I mentioned, you'll see that wildcard matching only occurs if either the URL starts with "*." (extension mapping) or if it starts with "/" and ends with "/*" (path mapping). Since "/*.do" is neither of those, exact matching is done. That means the "*" character is not a wildcard, but a literal character. This pattern would match

but not

Since URLs do not generally contain a "*" character anyway, this url-pattern is of little use.
[ April 16, 2008: Message edited by: Ulf Dittmer ]
 
John Pearson
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
/*.do is not a valid mapping, at least not in Tomcat.

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".
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John is correct.

/*.do is not valid.

Please see this thread for more info.
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now my curiosity is piqued. Section 11.2 of the servlet spec mentions that all patterns that do not fulfill the two conditions for wildcard mapping are treated as exact match mappings. It does not say that patterns containing the "*" need to be valid wildcard mappings. If that were the case, no "*" could be used in URLs, which doesn't sound right to me (even though this is pathological). Is this an implementation decision on Tomcat's part?
 
John Pearson
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wasn't able to find anything in the spec that specifically allowed or disallowed a "*" in this usage. I know it is allowed as a valid extension mapping character, so that something like */* or */*x* does work, matching anything ending with "*" or "*x*". So it seems very inconsistent that it doesn't work with "/*.do".

It would be interesting to know how other containers handle it. It's possible that this is a Tomcat specific implementation decision, or even a bug in Tomcat.
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I missed your previous comment, Ulf. Sorry. Yes, the ultra-anal interpretation of the spec should allow /*.do and it would follow literal and not the wildcard form.

I even had to check that * is a valid URL character since I don't think I've ever noticed one before.

Personally, I like that Tomcat creates an error. It's incredibly likely that any developer specifying /*.do really wanted the wildcard form and would have a heck of a time figuring out why it isn't working as desired.
 
John Pearson
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After reading the spec again, and reading RFC 1738 on URLs, I have to agree with you guys that /*.do should be allowed; it just isn't, at least not by Tomcat. When I get a chance, I'll check it with another container to see how it's handled.

So now I'm really not sure what to tell someone on how to answer this if it shows up on the test.
 
dhwani mathur
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Thanks a bunch Ulf Dittmer !!





for such a good explanation
now i am clear with the concept.

SCJP(1.5),SCWCD(Preparing...)
Dhwani:>Winning is not important but it is the only thing.
 
amit gupta
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well Dwani,

I hope everything you needed has been explained by my intelligent friends.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic