spauny
spauny

Reputation: 5116

Why jsf can't handle jsf error pages?

I have an error page error.jsf mentioned in the web.xml:

<error-page>
    <exception-type>javax.faces.application.ViewExpiredException</exception-type>
    <location>/viewExpired.jsp</location>
</error-page>
<error-page>
    <exception-type>java.lang.Throwable</exception-type>
    <location>/error.jsp</location>
</error-page>

If the file is .jsf the error page isn't triggered, when I change it to .jsp everything is OK. I've also implemented a filter but still nothing.

<filter>
    <filter-name>Error</filter-name>
    <filter-class>creazione.exception.MyFilter</filter-class>
</filter>

Is it something that JSF can't handle?

UPDATE The code from web.xml with the url-pattern mappings:

<servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>2</load-on-startup>
</servlet>
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>*.html</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
</servlet-mapping>

Upvotes: 3

Views: 3923

Answers (1)

BalusC
BalusC

Reputation: 1109874

That can happen if you're actually using Facelets as default view technology, as standardized in JSF 2.0. Your question history also confirms that you're using Facelets instead of its legacy predecesor JSP. You need to make those error pages Facelets files as well instead of JSP files.

That the filter is not "working" is caused by something else. Filters have totally no problem to run in combination with JSF.

Upvotes: 2

Related Questions