8i | 9i | 10g | 11g | 12c | 13c | 18c | 19c | 21c | 23c | Misc | PL/SQL | SQL | RAC | WebLogic | Linux

Home » Articles » Linux » Here

Apache Tomcat : Default Redirect

This article explains how to perform a redirect from the root location on an Apache Tomcat installation to a specific page.

Related articles.

The Problem

When you deploy applications to Tomcat, they create new subdirectories in the "webapps" folder and those folder names are part of URLs for that application. For example, when deploying Pure by Elsevier, the "webapps" directory looks like this.

$ ls
admin  portal  ws
$

The default page for the installation should be something like this.

So how do you make the base URL redirect to the login page, without reverting to HTTP redirects from a web server or reverse proxy?

The Solution

If you don't already have one, create a "ROOT" directory under the "webapps" directory.

$ mkdir $CATALINA_HOME/webapps/ROOT

Create a file called "index.jsp" in the "ROOT" directory with the following contents. If the file is already present, amend it.

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<html>
<head>
    <title>JSP Redirect</title>
    </head>
    <body>
       <%
          String redirectURL = "https://pure.example/admin/login.xhtml";
          response.sendRedirect(redirectURL);
        %>
    </body>
</html>

As soon as this file is in place, you will see the redirect is working, such that the following URL.

Is Redirected to the required URL.

For more information see:

Hope this helps. Regards Tim...

Back to the Top.