-
1. Re: Redirect URL in Tomcat
Laurent MatheoAug 7, 2014 1:25 PM (in response to Rakesh Jajper)
1 of 1 people found this helpfulTbh it would be easier with an Apache HTTPD, you would have much more options (redirect in VirtualHost, or URL Rewrite...):
URL Aliasing, Redirection, Rewriting and Reverse Proxying using Apache HTTPD
Doing this with Tomcat seems to be quite a headache:
http://nematodes.org/martin/2010/02/04/301-permanent-redirect-with-tomcat-howto/
http://stackoverflow.com/questions/1121858/redirect-all-requests-for-a-subdirectory-in-tomcat-6-0
Maybe in your case if you want a single redirect you could just put an Apache HTTPD on Mid-Tier server 1 and redirect everything to Server 2?
It sounds easier to setup.
-
2. Re: Redirect URL in Tomcat
Charles Golding Aug 7, 2014 1:28 PM (in response to Rakesh Jajper)Do you need all traffic redirected to server 2 or just the login?
-
3. Re: Redirect URL in Tomcat
Rakesh Jajper Aug 7, 2014 1:30 PM (in response to Charles Golding)All traffic, as Server 2 will be replacement server for Server 1
-
4. Re: Redirect URL in Tomcat
Charles Golding Aug 7, 2014 1:47 PM (in response to Rakesh Jajper)1 of 1 people found this helpfulI agree use apache httpd to do the url redirect.
Or you could replace the login.jsp page in server one with the following:code:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<html>
<head>
<title>JSP Redirect</title>
</head>
<body>
<%
String redirectURL = "http://Server2.comp.com:8080/arsys/home";
response.sendRedirect(redirectURL);
%>
</body>
</html>
-
5. Re: Redirect URL in Tomcat
Rakesh Jajper Aug 7, 2014 2:00 PM (in response to Charles Golding)Thanks This works, but its not working for specific URLs.
Like notification url send out to users, if they will click those which has Server1, and for specific ticket, it will open home page only as its redirecting to home.
I was looking something, where it will change just the Server reference with FQDN and leave other part of the URL as is.
-
6. Re: Redirect URL in Tomcat
Rakesh Jajper Aug 7, 2014 2:10 PM (in response to Laurent Matheo)Hi Laurent,
Can you give more insight to httpd file, where I can find it, or how I can write it.
I dont know much about Tomcat redirection.
If you can give me more details on it will help
-
7. Re: Redirect URL in Tomcat
Josh Taylor Aug 7, 2014 3:46 PM (in response to Rakesh Jajper)1 of 1 people found this helpfulWhat about just doing a simple redirect from the index.html page in Tomcat?
-
8. Re: Redirect URL in Tomcat
Jason MillerAug 7, 2014 11:58 PM (in response to Josh Taylor)
We commonly do this on our Mid Tier servers that do not have Apache HTTPD in front of them.
-
9. Re: Redirect URL in Tomcat
Anandsagar Sah Aug 8, 2014 2:15 AM (in response to Rakesh Jajper)1 of 1 people found this helpfulYou may configure redirect rules in ".htaccess" file.
When a URL is hit, it always checks for rules in htaccess file.
One of rule that you can configure is if a specific pattern in URL is hit, just redirect to another URL, with rest of parameters or part of URL as it is.
Link:
Thanks
Anandsagar
-
10. Re: Redirect URL in Tomcat
Laurent MatheoAug 8, 2014 3:09 AM (in response to Anandsagar Sah)
Yes but you need Apache HTTPD for this, not Tomcat.
-
11. Re: Redirect URL in Tomcat
Rakesh Jajper Aug 8, 2014 8:44 AM (in response to Anandsagar Sah)Hi Anand,
Can you tell me where should I put this file .htaccess. do you have any sample file.
-
12. Re: Redirect URL in Tomcat
Charles Golding Aug 11, 2014 4:26 PM (in response to Rakesh Jajper)Like Laurent has said, Tomcat has no .htaccess files.
and there is no index.html page either.
Can you send me a specific example of a URL that it does not work with, and I will see what I can come up with.
-
13. Re: Redirect URL in Tomcat
Rakesh Jajper Aug 13, 2014 8:46 AM (in response to Charles Golding)I could able to redirect all requests from Server 1 to Server 2, but each time it opens home page directly.
For example if I have direct URL for Approval Central then it should redirect to Server 2 and open Approval central but it redirected successfully but open home page instead Approval Central.
I wan something where it will redirect only first part of URL i.e. till /arsys, if URL contains:
http://server1:8080/arsys/URL-PART then redirect to http://server2:8080/arsys/URL-PART
It should leave as is after /arsys/. Because we have so many direct URLs for specific forms.
-
14. Re: Redirect URL in Tomcat
Charles Golding Aug 13, 2014 1:12 PM (in response to Rakesh Jajper)Do you use the ViewForm Servlet method of direct url [ViewFormServlet?server=<server>&for...] or do you use
The direct method[ /forms/<webserver>/<formname>/]
for direct urls?