File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Two servlets with same URL? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Two servlets with same URL?" Watch "Two servlets with same URL?" New topic
Author

Two servlets with same URL?

anish manikandan
Greenhorn

Joined: May 05, 2008
Posts: 1
Hi all,

I wanted to know if this crazy idea would work.

I have a servlet which acts as an entry point to my web service which is coded in Java completely. Now, I want to change the same web service to AXIS. I don't want to change the URL for it on my web server. And I want to deploy both of them at the same time, and route requests to the corresponding service depending on the requests.

I hope now you believe I'm crazy.

I want to know if there is a way I can implement this.

Thanks,
Anish
[ May 08, 2008: Message edited by: Bear Bibeault ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61218
    
  66

and route requests to the corresponding service depending on the requests.
If the URL for the requests are identical, on what basis would you propose determine which to activate?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Dan Walin
Ranch Hand

Joined: Nov 11, 2003
Posts: 109
I would think if there was a parameter in the URL that indicated which web service to call, the servlet could read the parameter and call the correct web service based on that.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61218
    
  66

Originally posted by Dan Walin:
I would think if there was a parameter in the URL that indicated which web service to call ...
But then, of course, it's no longer the same URL.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12787
    
    5
If all requests came first to a filer, you could use something in the request headers to decide which servlet to call. For example you could have different servlets for different Accept-* headers.

In the Jersey project for RESTful web services the container can direct requests according to the Accept media type. So if the request type was for XML it could go to the new AXIS based servlet.

Bill
[ May 09, 2008: Message edited by: William Brogden ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Two servlets with same URL?