Redirect Tomcat Homepage to Another URL

Assalamualaikum..

To redirect the Tomcat home page we need to edit file index.jsp (/opt/tomcat/webapps/ROOT/index.jsp). It is a good idea to backup the file before you doing any modification to the file. Below steps was tested on Tomcat 9.

Step 1: To make a backup file:

cp -rp index.jsp index.jsp.bak

Step 2: Now truncate the file using below cmd

> index.jsp

Step 3: Content index.jsp should be empty now. Then put below code to index.jsp

<%@ 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://example.com.au/jasperserver-pro/";
          response.sendRedirect(redirectURL);
        %>
    </body>
</html>

Step 4: Refresh your Tomcat home page

Click refresh button. Now you should see your Tomcat home page was redirect to https://example.com.au/jasperserver-pro/

thanks

Wassalam

This entry was posted in tomcat and tagged . Bookmark the permalink.