• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unusual servlet URL mapping -- is this possible?

 
James Adams
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • 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
 
Katrina Owen
Sheriff
Posts: 1367
18
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Thanks for your attention/suggestion Katrina.

--James
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic