Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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

HF S&J Error page:587-588

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While mapping URLs the third URL in the "Be The Container".

It says http://localhost:8080/MapTest/fooStuff/bar/blue.do should map to

DeployTestTwo servlet but in the Answers section on page 588

It says "DeployTestThree". Although longest path is /fooStuff/bar so it

should be DeployTestTwo as corerct answer and I also confirmed it from Tomcat

Server after matching this URL pattern.

Please correct me if I am wrong.
 
Cowgirl and Author
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm... I'll take a look at that, but I think our answers are correct, so I'm not sure what Tomcat is doing. Here's the reason:

The servlet mapping for DeployTestTwo is a URL pattern /fooStuff/bar, which is an exact match.

So the /fooStuff/bar/blue.do does not match that URL pattern exactly. If DeployTestTwo was mapped to /fooStuff/bar/*, then you are correct, and /fooStuff/bar/blue.do would have been the closest match. But since /fooStuff/bar is an *exact match* URL pattern, the /fooStuff/bar/blue.do matched to the URL pattern /fooStuff/*

Does that make sense? So while it is true that the longest match will win, this only works when you are not talking about an *exact* match. In an exact match URL pattern, like /fooStuff/bar, only an exact match will work.

Hmmmm... can you check this again in Tomcat? I'm going to do the same...

thanks,
Kathy
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bahadar/Kathy,

I've tried this out on Tomcat 5.0.28 on XP, and my results agree with Kathy & HFS. It maps to DeployTestThree.

I also tried putting in a mapping to /fooStuff/bar/* as well as /fooStuff/bar, which made the request map to /fooStuff/bar/* instead as Kathy suggested. Perhaps you inadvertently put this in your DD?
 
Bahadar Khan
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kathy/Rogers

Probably I have made some mistake, but as that code is not infront of me where I tested before. But now here in my home, I have tested this on three servers, Tomcat 4.0, Tomcat 5.0 and Weblogic 8.1, and it is following the *exact* URL rules. So answer is correct. But I would like to finish this thread until tomorrow morning where I would be able to see the previous code that made me to write this error. I think the server there was something 4.x.

Thanks to both of you for help, I will write more on it tomorrow after looking at other code.
 
Kathy Sierra
Cowgirl and Author
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This stuff is always tricky to test, because you often won't get any errors about what is in your DD, and because different versions of Containers do not always follow the spec *exactly*. What is in the book has all been tested on Tomcat 5, but even slight variations in versions of Tomcat can sometimes show different results. Ahhh... for the good old days when all you had to do was run javac and java to test everything

cheers,
Kathy
 
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kathy,


you often won't get any errors about what is in your DD, and because different versions of Containers do not always follow the spec *exactly*.


In such sense, what is the best (or better) practices for us to discover such problems?

Are there any convenient ways?

Nick
    Bookmark Topic Watch Topic
  • New Topic