Try this out. I did not check it.

In the while loop, instead of repeating
<%=objRs.getString("product_category") many times, get it in a variable just
after

while(obsRs.next()) {
String str_ProductCategory = obsRs.getString("product_category");

and use this variable elsewhere in the while loop.  (It makes better
prgramming sense also)

Regards,
Dantus

----- Original Message -----
From: Duc Nguyen
To: [EMAIL PROTECTED]
Sent: Saturday, February 24, 2001 3:05 AM
Subject: What's wrong with this code


Hi,
I am new to JSP, I have this code to query out a recordset and display it on
the screen.

<html>
<head><title>Manage Products</title></head>
<body>
<%@ page import="java.sql.*"%> <jsp:useBean id = "product"
class="ProductBean" scope="request" />
<jsp:setProperty name = "product" property="*"/> <%
 ResultSet objRs = product.getCategory();
%>
<%
 String cat;
 cat = request.getParameter("cat");
 if
t=="Home"){
%>
<font color="red"><b>Home</b></font>
<%
 }
 else{
%>
<a href="default.jsp?cat=Home">Home</a>
<%
 }
%>
<UL>
<%
 while(objRs.next())
 {
  if (cat == <%=objRs.getString("product_category")){
%>
  <Li><font color="red"><b><%=objRs.getString("product_category")%></b></font></Li>
</UL>
<%
  }
  ! ;else{
%>
<ul>
  <li><a href="default.jsp"><%=objRs.getString("product_category")%></a></li>
</ul>
<%
  }
 }
%>
</body>
</html>
I know that the bean is working fine however I got this error when I try to execute 
this page.

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to