ajax - Why FullAjaxExceptionHandler does not simply perform an ExternalContext#redirect()? -
in omnifaces, fullajaxexceptionhandler, after having found right error page use, calls jsf runtime build view , render instead of page includes ajax call.
why this? imho simpler perform externalcontext#redirect()
? there specific reasons this?
we writing our own exceptionhandler based on fullajaxexceptionhandler , wanted understand reason behind design.
the primary goal of fullajaxexceptionhandler
let exceptions during ajax requests behave exactly same exceptions during non-ajax requests. developer must able reuse error pages across both conditions without worrying condition while implementing error pages.
a redirect isn't part of normal flow during non-ajax requests. default <error-page>
mechanism in web.xml
performs forward display error page, not redirect. if redirect performed, error page request attributes such javax.servlet.error.exception
lost , render null
. moreover, normal practice place error pages in /web-inf
prevent endusers being able directly access (and bookmark , share) them. redirect require them publicly accessible, indicates major design problem (is intented target page real error page?).
if need perform redirect to/from error page, either homegrow custom exception handler explicitly invokes externalcontext#redirect()
, doesn't utilize web.xml
<error-page>
mechanism, or add <meta http-equiv="refresh" ...>
html head of error page in question (example here).
in case intended redirect login page when viewexpiredexception
occurs, should realize there's big difference between cases of "user not logged in" , "session/view expired". former, should not catching viewexpiredexception
@ all, use simple servlet filter checks if user logged in , redirect accordingly, long before facesservlet
invoked. normal authentication framework (jaas, shiro, spring security, etc) works way.
see also:
- what approach forward exception servlets jsp page?
- what difference between redirect , navigation/forward , when use what?
- why use jsf exceptionhandlerfactory instead of <error-page> redirection?
- check if session exists jsf
- authorization redirect on session expiration not work on submitting jsf form, page stays same
Comments
Post a Comment