Forums

This topic is locked

JSP Dynamic List/Menu

Posted 28 Nov 2005 07:59:24
1
has voted
28 Nov 2005 07:59:24 Debborah Kerr posted:
Hi Everyone,

I'm working with JSP, an Oracle database (and have tried Access database) using DWMX2004.

I'm trying to create a basic list/menu which is dynamically populated from my Recordset. I have done this numerous times with ASP, but with JSP it simply doesn't work.

I have read the technote www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_15038, but this is 4 years old and the code is quite different to mine.

When I insert the list/menu and populate it from the recordset, the resulting web page shows an empty list/menu. I applied the latest Dreamweaver update (7), and the error I get now is an Apache Error 500: "No data found".

Can anyone help? THis is basic Dreamweaver functionality that works in ASP, but not JSP.

My code is below - thank you. Deb.

<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<%@ include file="../../Connections/ecoa_dev.jsp" %>
<%
Driver DriverrsDept = (Driver)Class.forName(MM_ecoa_dev_DRIVER).newInstance();
Connection ConnrsDept = DriverManager.getConnection(MM_ecoa_dev_STRING,MM_ecoa_dev_USERNAME,MM_ecoa_dev_PASSWORD);
PreparedStatement StatementrsDept = ConnrsDept.prepareStatement("SELECT * FROM ecoa.DEPARTMENT";
ResultSet rsDept = StatementrsDept.executeQuery();
boolean rsDept_isEmpty = !rsDept.next();
boolean rsDept_hasData = !rsDept_isEmpty;
Object rsDept_data;
int rsDept_numRows = 0;
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<form name="form1" method="post" action="">
Department:
<select name="select">
<%
while (rsDept_hasData) {
%>
<option value="<%=((rsDept.getObject("DEPARTMENT"!=null)?rsDept.getObject("DEPARTMENT":""%>"><%=((rsDept.getObject("DEPARTMENT"!=null)?rsDept.getObject("DEPARTMENT":""%></option>
<%
rsDept_hasData = rsDept.next();
}
rsDept.close();
rsDept = StatementrsDept.executeQuery();
rsDept_hasData = rsDept.next();
rsDept_isEmpty = !rsDept_hasData;
%>
</select>
</form>
</body>
</html>
<%
rsDept.close();
StatementrsDept.close();
ConnrsDept.close();
%>


Reply to this topic