• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Unusual servlet URL mapping -- is this possible?

 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to have all requests URLs go to a single main servlet except if the request URL begins with "test", which should go to a test servlet.

For example, all of these URLs should go to the main servlet:

domain/update
domain/remove
account
account/update
anyuri
anyuri/blahblah

These URLs should go to the test servlet:

test/ping
test/read
test/write

I have tried the following in my web.xml but it doesn't work:


Can the mapping I'm shooting for even be done? If so then can someone suggest another mapping strategy to pull this off?

Thanks in advance for any suggestions.

--James
 
Sheriff
Posts: 1367
18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi James,

I think that what you are doing should work if you are using tomcat (not sure about others). I heard talk of a bug in some of the older tomcat versions that didn't deal with this correctly. Have you tried upgrading to the latest version?

Katrina
 
James Adams
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It turns out that this mapping is possible and that I just hadn't taken care of using the proper mapping ordering of the JAX-WS endpoints being used by my application. It seems that if your servlets are actually JAX-WS endpoints, as mine are, then you need to also have the endpoint mappings in the right order as well in sun-jaxws.xml. I didn't mention that I was using JAX-WS in my original post because I didn't think that it was relevant, but it turns out that the ordering of the JAX-WS endpoints has real implications here and is critical to getting this to work as desired.

As an example below are the relevant sections from the web.xml and sun-jaxws.xml files for my application, which is now working as described in my original post.

web.xml:



sun-jaxws.xml:



I hope this information will be helpful to someone else in the future.

--James
 
James Adams
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your attention/suggestion Katrina.

--James
 
Seriously? That's what you're going with? I prefer this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic