Bookmark Topic Watch Topic
  • New Topic

Help with JSP!!!  RSS feed

Posts: 7
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi all! I just thought I can some attention from the experts with JSP if I start a new thread than keep adding to the previous one. Anyhow, enclosed is my jsp. I am at my wit's end trying to figure out what is going wrong. Anyhow, to describe, the while ( loop gets me all records from my table fine. But, if I add the HTML tags(code) for displaying the same records using rs.getInt(1) etc., it results in the following error, AFTER fetching the 1st record:This is from my stdout.log. If I remove any kind of display html (I even tried it with adding the fetched records to an array, but with no luck) etc. results in the same error. Please please...please help!!
Here is the error from the STDOUT.log file:
Inside the ViewAds.jsp
Got more rows
Fetched record:
1Car1993 Mazda RX-5Speed-72K-New tires/battery.
*** SQLException caught ***
No data found
Here is my JSP:
<%@ page import="com.project.source.Ad" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<jsp:useBean id="adStore" scope="application" class="com.project.source.AdStore"/>
String base = (String) application.getAttribute("base");
<table width="97%" >
<td colspan="2"><jsp:include page = "Top.jsp" flush="true"/></td>
<td width="39%" height="500"><jsp:include page= "left.jsp" flush="true"/> </td>
<td width="67%" valign="top"><div align="center"><font size="6">View Ad and Place Bids</font><br>
<table width="100%" height="61" border="1" align="center" bordercolor="#666666">
<tr bgcolor="#CCCCCC">
<td width="28%" height="30"><div align="center"><font color="#FFFFFF">Ad
<td width="33%"><div align="center"><font color="#FFFFFF">Item</font></div></td>
<td width="39%"><div align="center"><font color="#FFFFFF">Short Description</font></div></td>
<td width="40%"><div align="center"><font color="#FFFFFF">View Details</font></div></td>
System.out.println("Inside the ViewAds.jsp\n");
Connection dbconn;
PreparedStatement sql;
String activeStatus = "A";
ArrayList adArray = null;

String dbUrl = "jdbc dbc rojectdb";
String dbUserName = "";
String dbPassword = "";

int ad = 0;
String shortD = "";
String longD = "";

//loading the database jdbc driver
dbconn = DriverManager.getConnection(dbUrl, dbUserName, dbPassword);
sql = dbconn.prepareStatement("SELECT AdStore.AdId, " +
"AdStore.AdType, " +
"AdStore.AdDesc FROM AdStore " +
"WHERE (((AdStore.AdStatus)='" + activeStatus + "'))");
ResultSet rs = (ResultSet) sql.executeQuery();
int recnum = 0;
System.out.println("Got more rows\n");
recnum ++;
System.out.println("Fetched record: \n" +
rs.getInt(1) + rs.getString(2) + rs.getString(3) + "\n");
<TD><FONT FACE="Verdana" SIZE="3"><%=rs.getInt(1)%></FONT></TD>
System.out.println("Total recs: " + recnum + "\n");
System.out.println("The array has:\n" + adArray);
catch (SQLException ex) {
System.out.println("*** SQLException caught ***\n");
while (ex != null) {
System.out.println("SQLState: \n" + ex.getSQLState());
System.out.println("Message: \n" + ex.getMessage());
System.out.println("Vendor: \n" + ex.getErrorCode());
ex = ex.getNextException();
catch (java.lang.Exception ex) {
catch (ClassNotFoundException e)
<td><INPUT TYPE="HIDDEN" NAME="formName" VALUE="ViewAd">
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!