I've written a servlet which queries a database for a list of messages, the output is directed to servlet generated html. The user has the option of selecting to view a selected message by clicking a button
ResultSet rs = null;
try
{
startPage(response);
rs = statement.executeQuery(sql);
while(rs.next())
{
out.println("<tr>");
out.println("<td align=center>"+rs.getString("Heading")+"</td>");
out.println("");
out.println("<td align=center>"+rs.getString("Username")+"</td>");
out.println("");
out.println("<td align=center>"+rs.getString("DatePosted")+"</td>");
out.println("");
out.println("<td align=center><form action=dbShowMessage?action='"+rs.getString("Heading")+"'method=post><input value=VIEW type=submit></form></td>");
out.println("</tr>");
}
endPage(response);
}
The code compiles without any error, but when I invoke it using the web server the HTML page displays without the table containing the results or the buttons, but as soon as I remove the it displays everything; what am I doing wrong here.
Alternatively I tried it with a URL as follows:
out.println("<tr>");
out.println("<td align=center><a href=dbShowMessage?title="+rs.getString("Heading")+">"+rs.getString("Heading")+"</a></td>");
out.println("");
out.println("<td align=center>"+rs.getString("Username")+"</td>");
out.println("");
out.println("<td align=center>"+rs.getString("DatePosted")+"</td>");
out.println("");
out.println("</tr>");
Again it's the same out come; the links and the table displayed after invocation but as soon as I create the reference same story.