Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect from index page in Spring and Tomcat

I have a Spring application, which is running on Tomcat say at: http://example.com/foo/

DisplatcherServlet is mapped to app/*, for example, index page is:

http://example.com/foo/app/index.html

This is so because I have other servlets (for HttpRequestHandlers), e.g. mapped to service/*. This scheme is convenient to use because this way app/ and service/ can have different security settings.

What I want is http://example.com/foo to redirect to http://example.com/foo/app/index.html.

How do I achieve this?

like image 639
Infeligo Avatar asked Feb 25 '23 11:02

Infeligo


1 Answers

In your web.xml, you can define a welcome file, seen when navigating to the root of the app:

<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

You can then make a tiny index.jsp that redirects to where you want:

<% response.sendRedirect("app/index.html"); %>
like image 97
artbristol Avatar answered Feb 26 '23 23:02

artbristol