---------------------------------------------------------------------------
HARBOR: http://coolharbor.100free.com/index.htm
Now Tomcat is also a cool application server
---------------------------------------------------------------------------
----- Original Message ----- From: "Daniel M Garland" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <users@tomcat.apache.org>
Sent: Monday, October 15, 2007 1:52 PM
Subject: redirecting old context uris when moving context


Hi

I was formerly hosting a web application at

http://somehost/somecontext

which I am now hosting at

http://somehost

so that the context is now ROOT, instead of somecontext.

Is there a way of mapping / redirecting 'old' URI from somecontext to the ROOT, so that

http://somehost/somecontext/someuri
becomes
http://somehost/someuri

This would be advantageous to me because bookmarked / search-engine listings for /someuri are now giving a 404, which I'd prefer to be a redirect. There is also the matter of links on other websites.

I was looking through my code and I've never had to do it... but I'm thinking it must be a common thing. As one person said redirecting in the Apache front end is an option, but I'm wondering if its not possible to do it at TC level..

I would try this....

Make a servlet in the old Webapp One (somecontext)....
Map all the requests to it....
In doGet...
protected void doGet(HttpServletRequest req, HttpServletResponse res)

try this....

ServletContext  appTwoCtx=this.getServletContext().getContext("/ROOT");
RequestDispatcher dispatcherTwo = appTwoCtx.getRequestDispatcher(req.getContextPath()); //Will have to remove the CONTEXT... I think
dispatcher .forward(req, res);

Cant see why that shouldnt work.... ie all requests coming into the old app are just sent to root... Maybe for top pages its ok.... because I dont thhink sessions would tranfer well like this...

Dispatch has the advantage of being direct... ie it goes directly to the other webapp..

If this doesnt work.... then at worst you will replace the dispatch with

response.sendRedirect(urlLocation); //after modifying the URL

and all that means it that it will round trip through the browser...

Maybe?
Let us know if the dipatch worked across webapps.... good luck...


Thanks in advance
Dan Garland


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email ______________________________________________________________________

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to