jsf - FacesExceptionFilter OmniFaces using error pages inside WEB-INF -
hi guys need in using omnifaces feature.
i trying use facesexceptionfilter redirect user error page when exception encountered.
i have following web.xml config
<?xml version="1.0" encoding="utf-8"?>
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="webapp_id" version="3.0">
<display-name>xxxxx</display-name> <session-config> <session-timeout>1</session-timeout> </session-config> <welcome-file-list> <welcome-file>pages/secured/main.xhtml</welcome-file> </welcome-file-list> <servlet> <servlet-name>facesservlet</servlet-name> <servlet-class>javax.faces.webapp.facesservlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>facesservlet</servlet-name> <url-pattern>*.xhtml</url-pattern> </servlet-mapping> <context-param> <param-name>javax.servlet.jsp.jstl.fmt.localizationcontext</param-name> <param-value>resources.application</param-value> </context-param> <context-param> <param-name>javax.faces.state_saving_method</param-name> <param-value>client</param-value> </context-param> <context-param> <param-name>contextconfiglocation</param-name> <param-value>/web-inf/spring-application-context.xml</param-value> </context-param> <context-param> <param-name>facelets.development</param-name> <param-value>true</param-value> </context-param> <context-param> <param-name>javax.faces.facelets_refresh_period</param-name> <param-value>2</param-value> </context-param> <context-param> <param-name>primefaces.theme</param-name> <param-value>mytheme</param-value> </context-param> <context-param> <param-name>javax.faces.facelets_libraries</param-name> <param-value>/web-inf/springsecurity.taglib.xml</param-value> </context-param> <context-param> <param-name>javax.faces.separator_char</param-name> <param-value>_</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener> <listener> <listener-class>com.bdo.corpsoa.utilities.security.listeners.impl.corpsoasessionlistener</listener-class> </listener> <filter> <filter-name>facesexceptionfilter</filter-name> <filter-class>org.omnifaces.filter.facesexceptionfilter</filter-class> </filter> <filter-mapping> <filter-name>facesexceptionfilter</filter-name> <servlet-name>facesservlet</servlet-name> </filter-mapping> <context-param> <param-name>org.omnifaces.faces_views_scan_path</param-name> <param-value>/*.xhtml</param-value> </context-param> <context-param> <param-name>org.omnifaces.faces_views_path_action</param-name> <param-value>redirect_to_scanned_extensionless</param-value> </context-param> <!-- <filter> <filter-name>springsecurityfilterchain</filter-name> <filter-class>org.springframework.web.filter.delegatingfilterproxy</filter-class> </filter> <filter-mapping> <filter-name>springsecurityfilterchain</filter-name> <url-pattern>/*</url-pattern> <dispatcher>request</dispatcher> <dispatcher>forward</dispatcher> </filter-mapping> --> <error-page> <exception-type>javax.faces.application.viewexpiredexception</exception-type> <location>/web-inf/pages/errors/viewexpired.xhtml</location> </error-page> <error-page> <exception-type>java.lang.runtimeexception</exception-type> <location>/web-inf/pages/errors/unhandled.xhtml</location> </error-page> <error-page> <error-code>404</error-code> <location>/web-inf/pages/errors/pagenotfound.xhtml</location> </error-page> <error-page> <exception-type>java.io.filenotfoundexception</exception-type> <location>/web-inf/pages/errors/pagenotfound.xhtml</location> </error-page>
however when exception happens user redirected default 500 error page.
the redirection work if move error pages out of web-inf folder /web-inf/pages/errors/pagenotfound.xhtml --> /pages/errors/pagenotfound.xhtml
but mean error page can accessed directly. in omnifaces showcase should possible. don't know missing please help...
here web.xml of omnifaces showcase shows error pages in web-inf possible.
<?xml version="1.0" encoding="utf-8"?>
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" metadata-complete="false" > omnifaces showcase
<!-- standard jsf settings. --> <context-param> <param-name>javax.faces.facelets_buffer_size</param-name> <param-value>65535</param-value> <!-- 64kb. --> </context-param> <context-param> <param-name>javax.faces.facelets_refresh_period</param-name> <param-value>0</param-value> <!-- should -1 production. --> </context-param> <context-param> <param-name>javax.faces.facelets_libraries</param-name> <param-value>/web-inf/showcase.taglib.xml</param-value> </context-param> <context-param> <param-name>javax.faces.facelets_skip_comments</param-name> <param-value>true</param-value> </context-param> <!-- mojarra/ri specific settings. --> <context-param> <param-name>com.sun.faces.defaultresourcemaxage</param-name> <param-value>3628800000</param-value> <!-- 6 weeks. --> </context-param> <!-- myfaces specific settings. --> <context-param> <param-name>org.apache.myfaces.resource_max_time_expires</param-name> <param-value>3628800000</param-value> <!-- 6 weeks. --> </context-param> <context-param> <!-- myfaces , mojarra don't agree on default setting serializing state in session opposed storing reference. mojarra's default false, can switched true. myfaces' default true, , can switched false, below. see http://arjan-tijms.omnifaces.org/p/jsf-22.html#1127 --> <param-name>org.apache.myfaces.serialize_state_in_session</param-name> <param-value>false</param-value> </context-param> <!-- omnifaces specific settings. --> <context-param> <param-name>org.omnifaces.cache_setting_session_max_capacity</param-name> <param-value>6</param-value> </context-param> <context-param> <!-- files in 3 paths defined below scanned , made available extensionless jsf views. since no explicit extension given scanning, these paths should contain jsf (facelets) files. --> <param-name>org.omnifaces.faces_views_scan_paths</param-name> <param-value>/showcase,/etc,/demo</param-value> </context-param> <context-param> <!-- redirects faces views scanned /showcase/[page].xhtml /[page]. 404 preferred (and default), showcase app has published /showcase/[page].xhtml --> <param-name>org.omnifaces.faces_views_path_action</param-name> <param-value>redirect_to_scanned_extensionless</param-value> </context-param> <!-- servlets , filters. --> <servlet> <servlet-name>facesservlet</servlet-name> <servlet-class>javax.faces.webapp.facesservlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>facesservlet</servlet-name> <url-pattern>*.xhtml</url-pattern> </servlet-mapping> <filter> <filter-name>characterencodingfilter</filter-name> <filter-class>org.omnifaces.filter.characterencodingfilter</filter-class> </filter> <filter-mapping> <filter-name>characterencodingfilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter> <filter-name>facesexceptionfilter</filter-name> <filter-class>org.omnifaces.filter.facesexceptionfilter</filter-class> </filter> <filter-mapping> <filter-name>facesexceptionfilter</filter-name> <servlet-name>facesservlet</servlet-name> </filter-mapping> <filter> <filter-name>gzipresponsefilter</filter-name> <filter-class>org.omnifaces.filter.gzipresponsefilter</filter-class> </filter> <filter-mapping> <filter-name>gzipresponsefilter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>request</dispatcher> <dispatcher>error</dispatcher> </filter-mapping> <!-- welcome files, error pages , mime types. --> <session-config> <cookie-config> <http-only>true</http-only> </cookie-config> <tracking-mode>cookie</tracking-mode> </session-config> <welcome-file-list> <!-- note extension used here, since index file resides within root has not been configured facesviews scanning. --> <welcome-file>index.xhtml</welcome-file> </welcome-file-list> <error-page> <exception-type>javax.faces.application.viewexpiredexception</exception-type> <location>/web-inf/errorpages/expired.xhtml</location> </error-page> <error-page> <exception-type>java.sql.sqlexception</exception-type> <location>/web-inf/errorpages/database.xhtml</location> </error-page> <error-page> <exception-type>java.lang.runtimeexception</exception-type> <location>/web-inf/errorpages/bug.xhtml</location> </error-page> <error-page> <error-code>500</error-code> <location>/web-inf/errorpages/500.xhtml</location> </error-page> <error-page> <error-code>404</error-code> <location>/web-inf/errorpages/404.xhtml</location> </error-page> <mime-mapping> <!-- silence weblogic's annoying "jsf1091: no mime type found file" warning. --> <extension>xhtml</extension> <mime-type>text/html</mime-type> </mime-mapping>
summary
- redirect error pages work if outside web-inf.
- showcase shows should possible.
- i need help....
thank time
edit
it seems "redirect error pages work if outside web-inf." not true.
this error page displayed if outside of web-inf
<?xml version="1.0" encoding="iso-8859-1" ?> <!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" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui"> <h:body> <h1>#{"xxxxxxxx"}</h1> </h:body> </html>
this error page not displayed if outside of web-inf. result in default 404 page
<?xml version="1.0" encoding="iso-8859-1" ?> <!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" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui"> <h:body> <h1>zzzzzzzzz</h1> </h:body> </html>
it seems facesexceptionfilter working if place el expression or jsf component on jsf page.
for reason error page not work , produce default 404 page.
<?xml version="1.0" encoding="iso-8859-1" ?> <!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" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui"> <h:body> <h1>zzzzzzzzz</h1> </h:body> </html>
however error page work.
<?xml version="1.0" encoding="iso-8859-1" ?> <!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" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui"> <h:body> <h1>#{"xxxxxxxx"}</h1> </h:body> </html>
Comments
Post a Comment