aspose file tools*
The moose likes Servlets and the fly likes Unusual servlet URL mapping -- is this possible? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Unusual servlet URL mapping -- is this possible?" Watch "Unusual servlet URL mapping -- is this possible?" New topic
Author

Unusual servlet URL mapping -- is this possible?

James Adams
Ranch Hand

Joined: Sep 12, 2003
Posts: 188
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

Joined: Nov 03, 2006
Posts: 1367
    
  18
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

Joined: Sep 12, 2003
Posts: 188
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

Joined: Sep 12, 2003
Posts: 188
Thanks for your attention/suggestion Katrina.

--James
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unusual servlet URL mapping -- is this possible?