Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why jsf can't handle jsf error pages?

Tags:

java

jsp

jsf

jsf-2

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>
like image 320
spauny Avatar asked Aug 01 '26 06:08

spauny


1 Answers

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.

like image 182
BalusC Avatar answered Aug 03 '26 20:08

BalusC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!