|
...
try {
ResultSet rs = s.executeQuery ("select * from pictures");
response.setContentType ("image / jpeg");
OutputStream os = response.getOutputStream ();
out.write ("<table> <tr> <td> picture </ td> </ tr>");
while (rs.next ())
{
byte [] dt = rs.getBytes (2);
os.write (dt);
}
os.flush ();
rs.close ();
} catch (Exception e)
{
e.printStackTrace ();
throw new SQLException ("Error:" + e);
}
...
In SQL Server, there is a table named “pitures”, where the second field is of type “image”, there are three rows in the table, and the second field of each row is a .JPG image.
My question is: First, every time I read the data from the table using the above code and display it in the JSP page, only the picture in the first row is always displayed. No exception was thrown. Second, out.write () cannot output content to the JSP page.
Seeking a solution. |
|