Checking if database is available in JSP

I have a JSP that shows a JavaBean value that is fetched from my Oracle database.The bean class uses a helper Database connection class (DbConnClass) to connect to the database. Everything is working where the bean fetches the database info and I use the Getter and Setter methods to show the information.My only issue is how do I show the JSP if the database is not available. Currently I have ugly scriplets but was wondering if there is another way?

<%@ page import="java.sql.*, ..... " %>

<%

Connection connection =null;

connection =new DbConnClass().myConn();

%>

<jsp:useBean id="simple" class="mypack.MyBean">

<jsp:setProperty name="simple" property="name" />

</jsp:useBean>

Here is alot ofstatic words in a couple paragraphs

etc.................

etc.............

Now showing dynamic value from Java Beanif database is available:

<%

if(connection !=null)

{

%>

<jsp:getProperty name="simple" property="name" />

<%

}

else

{

out.write("Database is not available");

}

%>

[1694 byte] By [florida41a] at [2007-11-27 11:52:25]
# 1

Well, maybe you can use a "try-catch-finally" for this one...

JSP try-catch-finally:

http://www.janeg.ca/scjp/flow/try.html

JS try-catch-finally:

http://www.topxml.com/javascript/javascript_error.asp

Hope it helps...

Regards!

Adrian

AdrianLabastidaa at 2007-7-29 18:44:24 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...