Hello all:

I find that the tag "<error-page>" could not be executed in my struts project.
It could not be forwarded to the "error.jsp" when I try to access a not exist page or a wrong url.Why?
The web.xml is like this:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
        <filter-name>Set Character Encoding</filter-name>
        <filter-name>Set Character Encoding</filter-name>
10 Years
Discussion Span
Last Post by lawrence_o

I am facing the same problem, Please let me know if you found any solution.


Well I have a workaround. I just add normal html pages as error pages BUT, in those particular html error pages, I do a redirect as follows:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    <META HTTP-EQUIV="Refresh" CONTENT="0;URL=../portal/unauthorized.action">


PAY ATTENTION: The ../blah blah/blah is important! because depending on the path where the user is coming from, it will work or it won't! So, either put all secured content in 1 and the same location to guarantee the path is always correct OR replace URL by:
URL=/context-root/action namespace/action.

I am talking about struts2 here.

The latter is NOT ideal because if the context-root is changed in your config, it won't work anymore! But I haven't found a better way yet. I will be lookin into the struts2 interceptors when I have time. I was also faced with the shit that when including jsp fragments in the error page mentioned in web.xml, I had nullPointerExceptions in the Struts2 tags!! I guess that's a nasty bug! Hope it will help you.

Cheers [email snipped]

Edited by Ezzaral: Added code tags and snipped email.

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.