You can use a Servlet filter ( link ), which will take the http request, interpret and convert it into a new url.
The installation is simple, just add the urlrewritefilter-4.0.3.jar file in WEB-INF / lib. In web.xml you add the following:
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
I suggest you read their documentation as well.