I need a suggestion. I am in the proces of designing
the web application using MVC pattern. And currently I
am designing a frame for our project.
one of the component of our frame work is error manager.
The functionality of the error manager is to catch any java language
exceptions and display a user defined error accrodingly. The user defined
error are stored in DB.
how do I achive this?
Get the error msg and display it to user at any point of time.
situation is as follows
1 Assume I have 8 pages to show and each page should be filled in before proceding to
next page. Say for example I got a Business rule validation erro in 5th page how
do I do this?
Please help me??
Here is one possible solution:
Say you have page1.jsp, page2.jsp,... page8.jsp
In each one of the JSP pages, preceeding all code that could potentially throw an exception, you can define the following directive:
<%@ page errorPage="myerror.jsp" %>
You will then need to define myerror.jsp page. That JSP page might look something like this:
<%@ page language="java" contentType="text/html" %>
<%@ page isErrorPage="true"%>
<h1>Houston we have a problem...</h1>
Say whatever else you want to say about how sorry you are that this error occured :)
The exception object is also available in this page, you can get at it as follows:
<%= exception.getMessage() %>
Since you say that you would like to display more user friendly messages, you'd somehow have already mapped these exceptions that you anticipate and have a corresponding message in the DB. Rather than displaying the exception message itself, you can now retrieve the error code from the database.
There is also a way of determining which page caused this error page to be invoked.
I can think of another way of doing this as well, using an exception handler class of sorts...
Hope that helps