T
teser3
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 of static words in a couple paragraphs
etc.................
etc.............
Now showing dynamic value from Java Bean if database is available:
<%
if(connection != null)
{
%>
<jsp:getProperty name="simple" property="name" />
<%
}
else
{
out.write("Database is not available");
}
%>
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 of static words in a couple paragraphs
etc.................
etc.............
Now showing dynamic value from Java Bean if database is available:
<%
if(connection != null)
{
%>
<jsp:getProperty name="simple" property="name" />
<%
}
else
{
out.write("Database is not available");
}
%>