Question

I am using spring 3 + Tomcat 7

In web.xml I have defined

<error-page>
    <error-code>404</error-code>
    <location>/filenotfound</location>
</error-page>

But i want to redirect to external url say www.google.com instead of /filenotfound . How can I do that ?

Was it helpful?

Solution

I am not sure whether giving the direct url in location will work. But you can put a jsp there and redirect to the url from the jsp.

<error-page>
    <error-code>404</error-code>
    <location>/filenotfound.jsp</location>
</error-page>

filenotfound.jsp

<%@ page language="java" %>  
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>  
<c:redirect url="http://hotmail.com" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top