Create A Centralized Redirect Using JSP

We have recently redesigned/reorganized our website (approximately 60,000 pages,  We have a large user base (basically the entire state of Wisconsin), who have bookmarked various pages on the old website.  As a courtesy to our customers, we want to have a centralized redirection system, that way we don't have to create a zillion different redirection pages.  In addition, we want the user to know that the page no longer exists and that they are being redirected to a new page (thus giving them the opportunity to update their bookmarks).

Possible Solution:
One solution that I have come up with is having one JSP page that accepts 2 parameters (the original page and the new page).  Since we are using Apache, we can setup redirects for a particular page that redirects the user to the JSP page (obviously passing the appropriate parameters), waits 5-10 seconds, and then sends them to the appropriate page.  The parameters will be used to display information back to the user and assist in redirecting to the new page (I hope that makes sense).

The Challenge:
Although the solution above might work, I wanted to pose the question to this community to get some various feedback.  I could very well just do a simple redirect using Apache and be done with it, but that does not prompt the user to update their bookmarks.  I could have also created the zillion pages and do the redirect that way as well... but that would be very labor intensive.  Has anyone else had to do something similar?  If so, how did you accomplish the task?

The best response get the max points...
Who is Participating?
objectsConnect With a Mentor Commented:
if you stored them in a db for example then all the redirecting jsp would need would be the old url.
u could then perhaps just redirect all missing pages which could lookup whether a redirect existed, and perform it if so.
the approach you are proposing sounds reasonable. How are u storing the redirect mappings?
kirbinatorAuthor Commented:
I was just going to add the redirects in the query string within the httpd.conf file.  Something like this

Redirect "/somedir/index.html" "/redirect.jsp?referring=/somedir/index.html&new=/newdir/index.html"

Do you know (or think) of a better way?

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

searlasConnect With a Mentor Commented:
If this is a reorganization (as you say), you should seriously consider RedirectPermanent and or 'RedirectMatch permanent', this allows some browsers to automatically update their Favorites/bookmarks without user intervention.
KarcOriginConnect With a Mentor Commented:

This is just an idea. Can you afford using XML mappings? Actually you need a controller JSP/Servlet which just read the XML file fetch the action (which is your old URLs in your case) mapped with the redirection page URL. By combining this approch you would never need to complie or change anything on JSP in future also. Just change the XML file which stores the mapping of actions and their corresponding redirection URL.

You can even avoid to restart your server once you change anything in the XML file. I hope this may give you some idea and the beauty of using XML as a redirection center of gravity. It is also better if you map your future "new URLs" with the "new actions" (It is just a suggestion)

KuldeepchaturvediConnect With a Mentor Commented:
Have you thought of using a filter servlet???
you will have to update your web.xml to have a filter setting on the web application.....

so automatically every request to your web site will go to this filter..

now this filter can choose any method to find the new page (either database,XML, or anything else that you might come up with to store the redirection mappings)..

All this filter will do is to read this mapping and redirect appropriately....

I know I am giving quite sketchy details here, but we can start and build as we go..

One option, if you are using is, that you can keep a redirect map either in memory or the DB.

Remove all the old files from the system, and in the web.xml, for a 404 error forward the request to the redirect JSP that will check whether .. the requested url is an old url or not.

If it is an old URL, you can redirect it to the correspoding new page using the redirect map, or else you can display the 404 error. :)
All Courses

From novice to tech pro — start learning today.