HP (Hewlett-Packard) 5991-5565 Network Card User Manual


 
1. Create a JSP file named $CATALINA_HOME/webapps/ROOT/oracleTest.jsp and insert
the following lines:
<%@page contentType="text/html" import="java.io.*,java.sql.*,
javax.sql.*,javax.naming.*"%>
<html>
<head>
<title>Tomcat->Oracle Test </title>
<link rel="stylesheet" href="style_master.css" type="text/css">
<meta http-equiv="cache-control" content="no-cache"></head>
<body>
<%
InitialContext ctx = new InitialContext();
DatabaseMetaData dm = null;
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/oracleDB");
Connection conn = null;
Statement stmt = null;
try {
conn = ds.getConnection();
dm =conn.getMetaData();
out.println("Connected to-> database version"
+dm.getDatabaseProductVersion());
}catch (Exception sqlex) {
out.println(sqlex.getMessage());
}finally{
conn.close();
}
%>
</body>
</html>
2. If the Tomcat Web server is not running, start it by entering the following command:
# $CATALINA_HOME/bin/startup.sh
3. Verify that the Oracle test page is displayed (Figure 13 ) by opening a browser and navigating
to the following website:
http://<YOUR_HOSTNAME>:8080/oracleTest.jsp
Figure 13 Oracle Database Test
Installing, Configuring, and Managing Web Server Middleware Stack Components 35