A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
Arduino in Action
this week in the
General Computing
forum!
A special promo:
Enter your blog post or vote on a blogger to be featured in an upcoming Journal
JavaRanch
»
Java Forums
»
Java
»
JSP
Author
help jsp catalog table 1row = 3itmes
sorimachi wong
Greenhorn
Joined: Apr 07, 2006
Posts: 3
posted
Apr 07, 2006 10:08:00
0
i create a simple shopping catalog..
when display 1 row = 3 items..
how to solve it ...
<%@ page import="java.sql.*" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>go to item product</title>
</head>
<body>
<%
String
item = request.getParameter("catalog");
Connection Con = null;
PreparedStatement
Ps = null;
ResultSet
Rs = null;
String sDB="test",sUsr="",sPwd="";
String sSQL = "select * from product where product_catalog = '"+item+"' order by product_id";
//Detect JDBC-ODBC driver
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch (Exception e) {
System.err.print("Jdbc.Open(): " + e.getMessage());
}
//connection to Database
try {
Con = DriverManager.getConnection(
"jdbc
dbc:" + sDB, sUsr, sPwd);
} catch (Exception e) {
System.err.print("Jdbc.Open(): " + e.getMessage());
}
//Run SQL Statement
try{
Ps = Con.prepareStatement(sSQL);
Rs = Ps.executeQuery();
}
catch(
SQLException
e){
System.err.println("Jdbc.Update(): " + e.getMessage());
}
%>
<table width='100%' border=0>
<tr>
<td align=center colspan=3><%= item %></td>
</tr>
<%
try {
while (Rs.next()){
if count mod 3=0 then
%>
<tr>
<td><p><a href="3.jsp?pid=<%=Rs.getString("product_id")%>">
<img src="<%=Rs.getString("product_desc")%>"><br>
<%=Rs.getString("product_name")%></a></p></td>
</tr>
<%
} else {
%>
<td><p><a href="3.jsp?pid=<%=Rs.getString("product_id")%>">
<img src="<%=Rs.getString("product_desc")%>"><br>
<%=Rs.getString("product_name")%></a></p></td>
<%
count=count+1
}
} catch (Exception e) {}
%>
</table>
</body>
<%
Con.close();
%>
</html>
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56529
14
I like...
posted
Apr 07, 2006 10:15:00
0
Originally posted by sorimachi wong:
how to solve it ...
How to solve
what
?
[
Smart Questions
] [
JSP FAQ
] [
Books by Bear
] [
Bear's FrontMan
] [
About Bear
]
sorimachi wong
Greenhorn
Joined: Apr 07, 2006
Posts: 3
posted
Apr 07, 2006 10:19:00
0
<%
try {
while (Rs.next()){
if count mod 3=0 then
%>
<tr>
<td><p><a href="3.jsp?pid=<%=Rs.getString("product_id")%>">
<img src="<%=Rs.getString("product_desc")%>"><br>
<%=Rs.getString("product_name")%></a></p></td>
</tr>
<%
} else {
%>
<td><p><a href="3.jsp?pid=<%=Rs.getString("product_id")%>">
<img src="<%=Rs.getString("product_desc")%>"><br>
<%=Rs.getString("product_name")%></a></p></td>
<%
count=count+1
}
} catch (Exception e) {}
%>
---------------------------------------------------
if count mod 3=0 then << this ...
I agree. Here's the link:
http://ej-technologies/jprofiler
- if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
subject: help jsp catalog table 1row = 3itmes
Similar Threads
SqlException accured at processing Jsp
what could be the reason behind this exception?
please figure this out..
Multiple forms in a single JSP page
error showing while retrieving the data from drop down list
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter