File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Redirecting The Request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Redirecting The Request" Watch "Redirecting The Request" New topic

Redirecting The Request

Rakesh Jhamb
Ranch Hand

Joined: Jun 18, 2003
Posts: 154
I have written a servlet that forwards the request to some other page using sendRedirect() and Location header . The servlet is properly written as mentioned in the book. Now i just want to know that suppose :-
I want that any request to should get redirected to, then how my servlet will get invoked. i.e. users will be using which will open and not my servlet, how can i get my servlet invoked from

R K Singh
Ranch Hand

Joined: Oct 15, 2001
Posts: 5382
you can set default page of your to the servlet which will redirect it to
you can set 404 error to the same servlet so any request for will also be directed to
But why do you want to take so much pain ? You[your service provider] can simply point both URL to single IP address.

"Thanks to Indian media who has over the period of time swiped out intellectual taste from mass Indian population." - Chetan Parekh
I agree. Here's the link:
subject: Redirecting The Request
jQuery in Action, 3rd edition