Thursday, May 20, 2010

Errror handling in JSF

1) Create a folder called error under webpages folder and create a jsp say
(error500.jsp,error400.jsp).....

place the below code in that jsp

<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<h1>Technical Problem Try Again</h1>
<%session.invalidate();%>
<a href="<%=request.getContextPath()%>/home.jsp">Home</a>
</body>
</html>

Note:home.jsp is the redirecting page when the error has occured.


2)Place the below code in web.xml

<!-- ======== Handling Exceptions Start ======== -->
<error-page>
<error-code>400</error-code>
<location>/error/error400.jsp</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/error/error404.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/error/error500.jsp</location>
</error-page>
<error-page>
<error-code>501</error-code>
<location>/error/error501.jsp</location>
</error-page>
<error-page>
<error-code>502</error-code>
<location>/error/error502.jsp</location>
</error-page>


<!-- ======== Handling Exceptions End ======== -->

JSF Related topics: JCaptcha in JSF, Integrating Richfaces with JSF,Getting client and server sessionId in JSF,PopUp AlertMessagebox for JSF and more.....

No comments:

Post a Comment