Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to setup redirect page for a changed URL

Posted on 2014-04-30
3
Medium Priority
?
255 Views
Last Modified: 2014-09-19
Here is our scenario:

We have a small in admin application(MVC app built in Eclipse with Spring running on a Tomcat 6 server)  which has been rebranded to address an internal reorganization. The URL of the application has changed to address the reorg with a new name.

The plan is to redirect any OLD url requests to the NEW url. Many users have various specific pages bookmarked with the OLD url.  We would like to do something that will tell the users that are still using the old URL that they are being redirected to the new URL and that they should change their bookmarks.  Just not sure how to do this?  So a inbound request with the OLD url could be redirected to the NEW url but we want to do something that will tell the user they are being automatically redirected first.  

Could this be done somehow by capturing the request in a 404 somehow then rendering a informational page before automatically redirecting the request to the correct NEW url?
Where would the informational page reside?

Any suggests, examples or samples would be greatly appreciated

Thank You
0
Comment
Question by:West100
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 28

Expert Comment

by:rrz
ID: 40032545
Tomcat could do this with a Filter. Requests for the old urls could be sent to your Filter and it could forward them to a JSP that could inform users of the changes and then after a few seconds refresh itself and then redirect to the new url.   I am assuming that you can keep a web app with the old name in  Tomcat.  Furthermore, if you do have both an old and new web apps with separate names, then the old one could be empty with just a error page that does the work of the Filter that I suggested.
If either of these is the way you want to go, then we can help you  implement it.  
But, maybe an expert has an easier way using your Apache  server.
0
 

Author Comment

by:West100
ID: 40032895
This might be a possibility but how does Tomcat get configured with a filter ..... We already have a 404.jsp in the app which gets triggered when a bad page is requested.  Not sure how we could leverage that? Sounds like some javascript would be needed? etc  We need more details .....

Thanks
0
 
LVL 28

Accepted Solution

by:
rrz earned 2000 total points
ID: 40033902
>We need more details .....  
Ok. But so do I.  
>The URL of the application has changed to address the reorg with a new name.  
Are you changing the name of the web app?
If so, then can you have two web apps? An old one and a new one?
Or are you leaving the name of web app the same?    
I am going to assume for now that you will have two web apps.
For this case, using an error page in the old web app would be the easiest way to go.
For the old web app, all you need is an empty shell of a web app; so that all requests have a response code of 404.
All you need is a web.xml file in a WEB-INF folder and a JSP. The web.xml file contains
 <error-page>
    <error-code>404</error-code>
    <location>/redirect.jsp</location>
 </error-page>

Open in new window

and redirect.jsp is something like
<%
   String path = "/newWebApp" + request.getServletPath();
   String queryString = request.getQueryString();
   if(queryString != null)path = path + "?" + queryString;

%>
<
<html>
<head>
<meta http-equiv="refresh" content="5; url=<%=path%>">
</head>
<body>
    You will be redirected. If it doesn't work, then use this link. <a href="<%=path%>"><%=path%></a>
</body>
</html>

Open in new window

   I don't know what your urls look like. But if you are not changing the name of your web app, then you could use a Filter.  The url-patterns  for the Filter  can be set up to catch the old names.  In the Filter's doFilter method, you could have the same kind of code that is in  redirect.jsp.  If you want some demonstration code, then ask us. I could do it tomorrow.
0

Featured Post

Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question