Вот минимальный web.xml
, который вы можете поместить в папку webapps (если вы не хотите менять 404 страницы по всему миру). Это позволит вам, например, перенаправить все запросы в новую папку.
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0"
metadata-complete="true">
<error-page>
<error-code>404</error-code>
<location>/redirect.jsp</location>
</error-page>
</web-app>
web.xml
Обратите внимание, что необходимо положить в .../webapps/YourFolder/WEB-INF/web.xml
.
В redirect.jsp
. Вы бы поставить что-то вроде:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<title>Moved</title>
</head>
<%
// get the requested URI
String requestedLocation = request.getRequestURI();
// rewrite to new location
String newLocation = requestedLocation.replaceAll("^/Old", "/New");
// 301 - permanent redirect
response.setStatus(response.SC_MOVED_PERMANENTLY);
response.setHeader("Location", newLocation);
%>
<body>
→ <a href="<%=newLocation%>"><%=newLocation%></a>
</body>
</html>
возможно дубликат [Ошибок страницы в Tomcat 7 для кода ошибки 500] (http://stackoverflow.com/questions/15987212/custom-error-page-in-tomcat- 7-for-error-code-500) –