• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

headings and data mismatch when there no link

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since this has become a purely HTML issue, I'm moving this off to the HTML/Javascript forum.
 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
It's exactly the same and completely different as this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic