This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

headings and data mismatch when there no link

 
orelia hans
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, Me again .
Well I am reading and writing data from my database table to my web page. When I put a link to one of the data, then my table headings matches the data bellow it. For exemple if there is a link on a data id, the heading " project id" will match with the corresponding data. But when there is no link, I have a extra column at the begining of my table. So project id or exemple doesn't have anything below it and and the end the last column wont have any heading. Tried everything but dunno why it's doing this.
My java code:

public String execute3(String st, Writer out)
{
String et = "unknown";
try
{
String sql = "SELECT * FROM Abbreviations WHERE TypeofAbbreviation = '" +st+"'";
Connection con = DriverManager.getConnection("jdbc dbc:AcessCore");
Statement s = con.createStatement();
ResultSet rs = s.executeQuery(sql);
while (rs.next())
{
String shtabbr = rs.getString(1);
String lngabbr = rs.getString(2);
out.write("<th>");
out.write("<td>"+shtabbr+"</td>");
out.write("<td>"+lngabbr+"</td>");
out.write( "</TR>" );
et = shtabbr;
}
rs.close();
s.close();
con.close();
}
catch (SQLException sqle)
{ sqle.printStackTrace();
}
catch(IOException eio)
{
}
return et;
}


My jsp code:
<%@ page import="Helper.*"%>
<%! CoreDataDetails coredataDetails = new CoreDataDetails();
%>
<form action="CoreDataDetails.java" method="POST">
<table border=0 align="center">
<tr>
<th class="title">
<h2><b>Abbreviations</b></h2>
</table>
<P>
<table border="1" cellpadding="5" width=450 align="center" bordercolor="#FF0000">
<tr> <b>
<th>Short Abbreviation
<th>Long Abbreviation</th> </b>
</tr><tr><% String shortab = coredataDetails.execute3("Government",out); %>
</table>
</form>
</body>


Thanks for your help
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64713
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your HTML is improperly formatted (missing closing tags and so on). Whether this is causing your problem or not isn't clear, but it's the first thing to clean up and check.
 
orelia hans
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear,
I checked my tags and realised I was using <th> instead of just <td>. For a row with a link I need <th> and for one with no link I just need <tr>.
Merci, gracias, thank you.
Almost the end...
I will be back for the implementation
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64713
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<th> should be used for column headers, and <td> should be used for the data cells. Whether they contain a link or not is moot. Be sure that they are properly nested and properly closed. A canonical table should look like this:

[ February 20, 2004: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64713
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since this has become a purely HTML issue, I'm moving this off to the HTML/Javascript forum.
 
Yuriy Fuksenko
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, just to be safe, I would declare connection, statement and resultset before "try{" and close them in "finally"
Connection con = null;
Statement s = null;
ResultSet rs = null;
try{
.....
}
catch(...){
...
}
finally{
if(rs != null) rs.close();
if(s != null) s.close();
if(con != null) con.close();
}
[ February 20, 2004: Message edited by: Yuriy Fuksenko ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic