aspose file tools*
The moose likes JSP and the fly likes Help with JSP!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply locked New topic
Author

Help with JSP!!!

Bhaskar Duvvuri
Greenhorn

Joined: Nov 30, 2003
Posts: 7
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 (rs.next()) 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 ***
SQLState:
null
Message:
No data found
Vendor:
0
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");
%>
<HTML>
<HEAD>
<TITLE>View Ads</TITLE>
</HEAD>
<BODY>
<table width="97%" >
<tr>
<td colspan="2"><jsp:include page = "Top.jsp" flush="true"/></td>
</tr>
<tr>
<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>
</div>
<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
Id</font></div></td>
<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>
</tr>
<%
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 = "";

try
{
//loading the database jdbc driver
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
try
{
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;
while(rs.next())
{
System.out.println("Got more rows\n");
recnum ++;
System.out.println("Fetched record: \n" +
rs.getInt(1) + rs.getString(2) + rs.getString(3) + "\n");
%>
<TR>
<TD><FONT FACE="Verdana" SIZE="3"><%=rs.getInt(1)%></FONT></TD>
</TR>
<%
}
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) {
ex.printStackTrace();
}
}
catch (ClassNotFoundException e)
{
System.out.println(e.toString());
}
%>
</TABLE>
<tr>
<td><INPUT TYPE="HIDDEN" NAME="formName" VALUE="ViewAd">
</tr>
</table>
</BODY>
</HTML>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help with JSP!!!