How should you address this?

You are implementing a model component. You realize that an IOException might arise if you lose
connection to the database. How should you address this?

You are implementing a model component. You realize that an IOException might arise if you lose
connection to the database. How should you address this?

A.
Implement multipathing to provide redundant connectivity to the database, thereby avoiding that
risk of connection failure.

B.
Provide an error handler page, and use the page directive in the invoking ISP to redirect to that
page if the error arises.

C.
Use the JSTL <c:catch> tag to take control if the exception arises.

D.
Surround the problem area with a try/catch block and implement appropriate recovery or
fallback behavior.

Explanation:
http://www.ibm.com/developerworks/java/library/j-jstl0318/ (topic: exception handling)



Leave a Reply 7

Your email address will not be published. Required fields are marked *


giuseppe

giuseppe

E everybody says so

I would have answered D, perhaps the model which he is referring to is a custom tag. Not very clear

noname

noname

implementing a MODEL component not a VIEW component, thus there should be no JSTL involved (C is wrong), D should be correct

LeoCode

LeoCode

C

The assumption is once an IOException is thrown, there is no way to reconnect to the database, hence you are left with JSTL, the view component, to display the appropriate error message.

http://stackoverflow.com/a/23054284

Google

Google

The time to read or visit the content or internet sites we’ve linked to beneath.

Allan Santos

Allan Santos

I guess the C is the correct.

Tiparega

Tiparega

I agree with noname as can only catch exceptions thrown in its body, so if Exception is thrown in the Servlet, there is no way can helps.
Only make sense if call to model or helper is in the JSP (which is bad use of MVC).