JSP Exception Handling in Same Page
posted 13 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I don't know if it's possible but I would like to handle exceptions in the same page of the form to avoid creating new pages just for exception handling.
For example I have business method: findByLastVisit(Date date);
That returns data or throws an exception if no data is found. On my jsp I have:
I would like to display those exceptions in the same place as errorInForm. How can I do this? Do I have to modify the web.xml to add the same page for exceptions?
For example I have business method: findByLastVisit(Date date);
That returns data or throws an exception if no data is found. On my jsp I have:
I would like to display those exceptions in the same place as errorInForm. How can I do this? Do I have to modify the web.xml to add the same page for exceptions?
regards,
Victor M. Pereira
posted 13 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
An exception means something has gone really really wrong. You should not be using exceptions for business errors such as form validation failures.
Victor M. Pereira
Ranch Hand
Posts: 50
posted 13 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Well is not really for form validation, I couldn't think of a better way of automatized messages.
regards,
Victor M. Pereira
posted 13 years ago
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
Exceptions shouldn't be used for messaging. That's like using nuclear weapons to crack walnuts. Exceptions are for horrible conditions like null pointer exceptions and illegal states.
It looks as if you are using Spring. Why aren't you using Spring's messaging?
It looks as if you are using Spring. Why aren't you using Spring's messaging?
Victor M. Pereira
Ranch Hand
Posts: 50
posted 13 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
You mean the resourcebundle of spring or by JMS?
regards,
Victor M. Pereira
posted 13 years ago
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
My quick answer - AJAXIZE the form post, and review the result. Come up with a JSON equivalent of an error list and convert it when received in your backend. There are probably built-in resources here for some of this. Roo includes a thin Spring Javascript livrary that wraps dojo and can convert form posts to ajax, but so does native Dojo and jQuery, etc.
So it could be (psuedo code here):
So it could be (psuedo code here):
Ken Rimple
[email protected]
Co-author, Manning Spring Roo in Action
I teach for Chariot Solutions (Spring, Maven, Hibernate, other courses). Schedule here
posted 13 years ago
Great minds think alike. This is exactly what I do. I didn't know if Spring had something built in -- I use native jQuery with the Forms and Validation plugins.
The best part is that, in the case of errors, no context is lost that needs to be painstakingly re-created when using a traditional full-page form post.
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
Ken Rimple wrote:My quick answer - AJAXIZE the form post, and review the result. Come up with a JSON equivalent of an error list and convert it when received in your backend.
Great minds think alike. This is exactly what I do. I didn't know if Spring had something built in -- I use native jQuery with the Forms and Validation plugins.
The best part is that, in the case of errors, no context is lost that needs to be painstakingly re-created when using a traditional full-page form post.
| Arthur, where are your pants? Check under this tiny ad. The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |










