Gar04
asked on
Need Help with formatting JSP
Hello Experts,
i have a jsp page below that has a for loop for reading in data
i am having difficulty getting the results to output in repeated rows
i think that i am placing the end of the for loop in the wrong place
to allow the rows to repeat when there is multiple data.
it works but it just looks bad
can anyone help me sort this out
it should be an easy 300 pts for yeah
unlike many of my other threads!!
Gaz :)
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" %>
<% Class.forName("sun.jdbc.od bc.JdbcOdb cDriver");
Connection conn = null;
CallableStatement cs = null;
try
{
conn = DriverManager.getConnectio n("jdbc:od bc:BillBoa rdCompany" );
cs = conn.prepareCall("{Call SiteSearchQ(?, ?, ?)}");
String snames[] = request.getParameterValues ("SiteName ");
for( int ii=0; snames!=null && ii<snames.length; ii++ )
{
String siteName = snames[ii];
//String siteName = request.getParameter("Site Name");
//if( siteName == null ) siteName = "";
int selCyc=Integer.parseInt( request.getParameter("Sele ctCyc"));
int year=Integer.parseInt( request.getParameter("Sele ctYear"));
//cs.setString(1, siteName );
cs.setString(1,siteName);
cs.setInt(2, selCyc );
cs.setInt(3, year);
ResultSet rs = cs.executeQuery();
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>SearchRes</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name=Bookform Action="BookingPage.jsp" method="post">
<table width="95%" border="1" align="center" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">
<!--DWLayoutTable-->
<tr>
<td height="74" colspan="4" align="left" valign="bottom" bgcolor="#FFFFFF">
<div align="right"></div>
<div align="left"></div>
<div align="left"></div>
<table width="99%" height="34" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#006699">
<tr bordercolor="#0033CC">
<td width="245" height="20" align="center" valign="middle"> <div align="center"></div>
<strong><font color="#000000" size="1"> </font></st rong><font color="#000000" size="1"><strong>Site
Location</strong></font></ td>
<td width="155" height="20" align="center" valign="middle"> <div align="center"><font color="#000000" size="1"><strong>Site
Format</strong></font></di v></td>
<td width="83" align="center" valign="middle"> <font color="#000000" size="1"> <strong>Pri smatic</st rong></fon t></td>
<td width="72" align="center" valign="middle" bgcolor="#FFFFFF"> <div align="center"><font color="#000000" size="1"><strong>Illuminat ed</strong ></font></ div></td>
<td width="67" align="center" valign="middle"> <div align="center"><font color="#000000" size="1"><strong>CycleStar t</strong> </font></d iv></td>
<td width="119" align="center" valign="middle"> <div align="center"><font color="#000000" size="1"></font></div>
<div align="center"></div>
<div align="center"><font color="#000000" size="1"><strong>CycleEnd< /strong></ font></div ></td>
<td colspan="2" align="center" valign="middle"> <div align="center">
<div align="center"><font color="#000000" size="1"></font></div>
<div align="center"><font size="1"><strong>Book</str ong></font ></div>
<font color="#000000" size="1"></font></div>
<div align="center"></div></td>
</tr>
<% while (rs.next())
{ %>
<tr bgcolor='#EEEFF3' onMouseOver="this.bgColor= '#B2C4F0'; " onMouseOut="this.bgColor=' #EEEFF3';" >
<input name="siteId" type="hidden" value="<%=rs.getString("Si teID")%>">
<td height="12"> <div align="center"></div>
<div align="center"></div>
<div align="center"><font color="#000000" size="1"><%=rs.getString(" SiteLocati on")%></fo nt></div>< /td>
<td><div align="center"><font color="#000000" size="1"><%=rs.getString(" SiteType") %></font>< /div></td>
<td><div align="center"><font color="#000000" size="1"><%=rs.getString ("Prismatic")%></font></di v></td>
<td><div align="center"><font color="#000000" size="1"><%=rs.getString ("Illuminated")%></font></ div></td>
<input name="cycleId" type="hidden" value="<%=rs.getString("Cy cleID")%>" >
<td><div align="center"><font color="#000000" size="1"><%=rs.getString ("CycleStart")%></font></d iv></td>
<td><div align="center"><font color="#000000" size="1"><%=rs.getString ("CycleEnd")%></font></div ></td>
<input name="bookYear" type="hidden" value="<%=rs.getString("Bo okYear")%> ">
<td width="120"><div align="center"><font color="#000000" size="1">
<input type="checkbox" name="bookingsNo" value="<%=rs.getString("Bo okingsNo") %>">
</font></div></td>
</tr>
<%} // end the while loop %>
<%}// end the for loop %>
</table>
<div align="center"> </div></td>
</tr>
<tr valign="middle">
<td colspan="4" align="center" bgcolor="#FFFFFF"></td>
</tr>
<tr valign="middle">
<td height="21" colspan="4" align="center" bgcolor="#FFFFFF"><!--DWLa youtEmptyC ell-->&nbs p;</td>
</tr>
<tr valign="middle">
<td align="center" bgcolor="#FFFFFF"><font size="1">Company Name</font></td>
<td align="center" bgcolor="#FFFFFF"><div align="left">
<input type="text" name="compName" value="">
</div></td>
<td align="center" bgcolor="#FFFFFF"><font size="1">Company Address</font></td>
<td align="center" bgcolor="#FFFFFF"><div align="left">
<input type="text" name="compAddress" value="">
</div></td>
</tr>
<tr valign="middle">
<td align="center" bgcolor="#FFFFFF"><font size="1">City </font></td>
<td align="center" bgcolor="#FFFFFF"><div align="left">
<input type="text" name="cityName" value="">
</div></td>
<td align="center" bgcolor="#FFFFFF"><font size="1">Country</font></t d>
<td align="center" bgcolor="#FFFFFF"><div align="left">
<input type="text" name="countryName" value="">
</div></td>
</tr>
<tr valign="middle">
<td align="center" bgcolor="#FFFFFF"><font size="1">Postcode</font></ td>
<td align="center" bgcolor="#FFFFFF"><div align="left">
<input type="text" name="postCode" value="">
</div></td>
<td align="center" bgcolor="#FFFFFF"><font size="1">Phone Number</font></td>
<td align="center" bgcolor="#FFFFFF"><div align="left">
<input type="text" name="phoneNum" value="">
</div></td>
</tr>
<tr valign="middle">
<td align="center" bgcolor="#FFFFFF"><font size="1">Fax Number</font></td>
<td align="center" bgcolor="#FFFFFF"><div align="left">
<input type="text" name="faxNum" value="">
</div></td>
<td align="center" bgcolor="#FFFFFF"><font size="1">Email Address</font></td>
<td align="center" bgcolor="#FFFFFF"><div align="left">
<input type="text" name="emailAdd" value="">
</div></td>
</tr>
<tr valign="middle">
<td align="center" bgcolor="#FFFFFF"><font size="1">Product Name</font></td>
<td align="center" bgcolor="#FFFFFF"><div align="left">
<input type="text" name="prodName" value="">
</div></td>
<td align="center" bgcolor="#FFFFFF"><font size="1">Product Category</font></td>
<td align="center" bgcolor="#FFFFFF"><div align="left">
<input type="text" name="prodCat" value="">
</div></td>
</tr>
<tr valign="middle">
<td align="center" bgcolor="#FFFFFF"><font size="1">Price</font></td>
<td align="center" bgcolor="#FFFFFF"><div align="left">
<input type="text" name="priceNum" value="">
</div></td>
<td align="center" bgcolor="#FFFFFF"><!--DWLa youtEmptyC ell-->&nbs p;</td>
<td align="center" bgcolor="#FFFFFF"><!--DWLa youtEmptyC ell-->&nbs p;</td>
</tr>
<tr valign="middle">
<td colspan="4" align="center" bgcolor="#FFFFFF"><input type=submit name=Submit value="BookIt"></td>
</tr>
</table>
</form>
<%
}
catch (Exception e)
{
e.printStackTrace() ;
out.print("Exception: " + e);
}
finally
{
if( cs != null ) try { cs.close(); } catch( Throwable t ) { t.printStackTrace(); }
if( conn != null ) try { conn.close(); } catch( Throwable t ) { t.printStackTrace(); }
}
%>
</body>
</html>
i have a jsp page below that has a for loop for reading in data
i am having difficulty getting the results to output in repeated rows
i think that i am placing the end of the for loop in the wrong place
to allow the rows to repeat when there is multiple data.
it works but it just looks bad
can anyone help me sort this out
it should be an easy 300 pts for yeah
unlike many of my other threads!!
Gaz :)
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" %>
<% Class.forName("sun.jdbc.od
Connection conn = null;
CallableStatement cs = null;
try
{
conn = DriverManager.getConnectio
cs = conn.prepareCall("{Call SiteSearchQ(?, ?, ?)}");
String snames[] = request.getParameterValues
for( int ii=0; snames!=null && ii<snames.length; ii++ )
{
String siteName = snames[ii];
//String siteName = request.getParameter("Site
//if( siteName == null ) siteName = "";
int selCyc=Integer.parseInt( request.getParameter("Sele
int year=Integer.parseInt( request.getParameter("Sele
//cs.setString(1, siteName );
cs.setString(1,siteName);
cs.setInt(2, selCyc );
cs.setInt(3, year);
ResultSet rs = cs.executeQuery();
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>SearchRes</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name=Bookform Action="BookingPage.jsp" method="post">
<table width="95%" border="1" align="center" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">
<!--DWLayoutTable-->
<tr>
<td height="74" colspan="4" align="left" valign="bottom" bgcolor="#FFFFFF">
<div align="right"></div>
<div align="left"></div>
<div align="left"></div>
<table width="99%" height="34" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#006699">
<tr bordercolor="#0033CC">
<td width="245" height="20" align="center" valign="middle"> <div align="center"></div>
<strong><font color="#000000" size="1"> </font></st
Location</strong></font></
<td width="155" height="20" align="center" valign="middle"> <div align="center"><font color="#000000" size="1"><strong>Site
Format</strong></font></di
<td width="83" align="center" valign="middle"> <font color="#000000" size="1"> <strong>Pri
<td width="72" align="center" valign="middle" bgcolor="#FFFFFF"> <div align="center"><font color="#000000" size="1"><strong>Illuminat
<td width="67" align="center" valign="middle"> <div align="center"><font color="#000000" size="1"><strong>CycleStar
<td width="119" align="center" valign="middle"> <div align="center"><font color="#000000" size="1"></font></div>
<div align="center"></div>
<div align="center"><font color="#000000" size="1"><strong>CycleEnd<
<td colspan="2" align="center" valign="middle"> <div align="center">
<div align="center"><font color="#000000" size="1"></font></div>
<div align="center"><font size="1"><strong>Book</str
<font color="#000000" size="1"></font></div>
<div align="center"></div></td>
</tr>
<% while (rs.next())
{ %>
<tr bgcolor='#EEEFF3' onMouseOver="this.bgColor=
<input name="siteId" type="hidden" value="<%=rs.getString("Si
<td height="12"> <div align="center"></div>
<div align="center"></div>
<div align="center"><font color="#000000" size="1"><%=rs.getString("
<td><div align="center"><font color="#000000" size="1"><%=rs.getString("
<td><div align="center"><font color="#000000" size="1"><%=rs.getString ("Prismatic")%></font></di
<td><div align="center"><font color="#000000" size="1"><%=rs.getString ("Illuminated")%></font></
<input name="cycleId" type="hidden" value="<%=rs.getString("Cy
<td><div align="center"><font color="#000000" size="1"><%=rs.getString ("CycleStart")%></font></d
<td><div align="center"><font color="#000000" size="1"><%=rs.getString ("CycleEnd")%></font></div
<input name="bookYear" type="hidden" value="<%=rs.getString("Bo
<td width="120"><div align="center"><font color="#000000" size="1">
<input type="checkbox" name="bookingsNo" value="<%=rs.getString("Bo
</font></div></td>
</tr>
<%} // end the while loop %>
<%}// end the for loop %>
</table>
<div align="center"> </div></td>
</tr>
<tr valign="middle">
<td colspan="4" align="center" bgcolor="#FFFFFF"></td>
</tr>
<tr valign="middle">
<td height="21" colspan="4" align="center" bgcolor="#FFFFFF"><!--DWLa
</tr>
<tr valign="middle">
<td align="center" bgcolor="#FFFFFF"><font size="1">Company Name</font></td>
<td align="center" bgcolor="#FFFFFF"><div align="left">
<input type="text" name="compName" value="">
</div></td>
<td align="center" bgcolor="#FFFFFF"><font size="1">Company Address</font></td>
<td align="center" bgcolor="#FFFFFF"><div align="left">
<input type="text" name="compAddress" value="">
</div></td>
</tr>
<tr valign="middle">
<td align="center" bgcolor="#FFFFFF"><font size="1">City </font></td>
<td align="center" bgcolor="#FFFFFF"><div align="left">
<input type="text" name="cityName" value="">
</div></td>
<td align="center" bgcolor="#FFFFFF"><font size="1">Country</font></t
<td align="center" bgcolor="#FFFFFF"><div align="left">
<input type="text" name="countryName" value="">
</div></td>
</tr>
<tr valign="middle">
<td align="center" bgcolor="#FFFFFF"><font size="1">Postcode</font></
<td align="center" bgcolor="#FFFFFF"><div align="left">
<input type="text" name="postCode" value="">
</div></td>
<td align="center" bgcolor="#FFFFFF"><font size="1">Phone Number</font></td>
<td align="center" bgcolor="#FFFFFF"><div align="left">
<input type="text" name="phoneNum" value="">
</div></td>
</tr>
<tr valign="middle">
<td align="center" bgcolor="#FFFFFF"><font size="1">Fax Number</font></td>
<td align="center" bgcolor="#FFFFFF"><div align="left">
<input type="text" name="faxNum" value="">
</div></td>
<td align="center" bgcolor="#FFFFFF"><font size="1">Email Address</font></td>
<td align="center" bgcolor="#FFFFFF"><div align="left">
<input type="text" name="emailAdd" value="">
</div></td>
</tr>
<tr valign="middle">
<td align="center" bgcolor="#FFFFFF"><font size="1">Product Name</font></td>
<td align="center" bgcolor="#FFFFFF"><div align="left">
<input type="text" name="prodName" value="">
</div></td>
<td align="center" bgcolor="#FFFFFF"><font size="1">Product Category</font></td>
<td align="center" bgcolor="#FFFFFF"><div align="left">
<input type="text" name="prodCat" value="">
</div></td>
</tr>
<tr valign="middle">
<td align="center" bgcolor="#FFFFFF"><font size="1">Price</font></td>
<td align="center" bgcolor="#FFFFFF"><div align="left">
<input type="text" name="priceNum" value="">
</div></td>
<td align="center" bgcolor="#FFFFFF"><!--DWLa
<td align="center" bgcolor="#FFFFFF"><!--DWLa
</tr>
<tr valign="middle">
<td colspan="4" align="center" bgcolor="#FFFFFF"><input type=submit name=Submit value="BookIt"></td>
</tr>
</table>
</form>
<%
}
catch (Exception e)
{
e.printStackTrace() ;
out.print("Exception: " + e);
}
finally
{
if( cs != null ) try { cs.close(); } catch( Throwable t ) { t.printStackTrace(); }
if( conn != null ) try { conn.close(); } catch( Throwable t ) { t.printStackTrace(); }
}
%>
</body>
</html>
Is there any error or exception throw out?
I think you just remove this line, I cannot see the matching for loop.
<%}// end the for loop %>
<%}// end the for loop %>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
or, if you want a form (and table) for each loop round the for loop, then move the end for down to after the table :-)
Tim
Tim
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
tim, you are the bomb!!!
cheers mate
it works fine
i was in a muddle with the formatting
my system is coming together now and it has been greatly helped
by some of the code you provided cos i have analysed and modified it for other
parts too.
sompol, thanks for you input too!!
:)
Gaz
cheers mate
it works fine
i was in a muddle with the formatting
my system is coming together now and it has been greatly helped
by some of the code you provided cos i have analysed and modified it for other
parts too.
sompol, thanks for you input too!!
:)
Gaz
:-) Good luck with it fella :-)
Glad I could help!
Hope you are ok!
Tim
Glad I could help!
Hope you are ok!
Tim