aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes headings and data mismatch when there no link Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "headings and data mismatch when there no link" Watch "headings and data mismatch when there no link" New topic
Author

headings and data mismatch when there no link

orelia hans
Ranch Hand

Joined: Jan 29, 2004
Posts: 37
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

Joined: Jan 10, 2002
Posts: 61768
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
orelia hans
Ranch Hand

Joined: Jan 29, 2004
Posts: 37
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

Joined: Jan 10, 2002
Posts: 61768
    
  67

<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

Joined: Jan 10, 2002
Posts: 61768
    
  67

Since this has become a purely HTML issue, I'm moving this off to the HTML/Javascript forum.
Yuriy Fuksenko
Ranch Hand

Joined: Feb 02, 2001
Posts: 413
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: headings and data mismatch when there no link