Sending error contents from JAVABEAN to JSP page
1 posts in topic
Flat View  Flat View

Posted By:   hari_krishnan
Posted On:   Thursday, December 19, 2002 01:44 AM

i Have a jsp page and i call a Simple JAVABEAN class from that. IF suppose i get an error inside the javabean class, i need to display that error in a formatted manner to the JSP page that is being displayed. Is there any solution like we do the same from servlets using PrintWriter. As PrintWriter is an method of ServletResponse, how can we use that inside JAVABEAN.

Re: Sending error contents from JAVABEAN to JSP page

Posted By:   Christopher_Koenigsberg  
Posted On:   Thursday, December 19, 2002 06:56 AM

I have a special jsp, "displayerrors.jsp" which I include via "jsp:include", inside a div, at the top of each main jsp.

I have some interfaces and classes to manage some special attributes, of request and/or session scope, for error messages. Inside the beans or whatever, if an error is encountered, it calls the management API to add an error text to the error messages attribute. (the management API also logs a more detailed message, via log4j, to the sysadmins, but a less detailed message, for the end user to see, goes to the error messages attributes)

When the displayerrors jsp runs, it formats the contents, if any, of the error messages attributes, from request and session scope.

(actually in real life it is even more complicated; it also handles multiple "success messages" as well as "failure messages" so an operation could come back to display "Found that user OK" as a partial success, but then "failed to delete that user" as a failure, etc.).

About | Sitemap | Contact