can i get the code to display multiple images in a webpage plz.
here is my code . dono wat modifications should be done . i want to display all images stored in particular table at once .






protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
//String photoid = request.getParameter("txtid");
Blob photo = null;
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;

String query = "select img from pic where idpic=2";
ServletOutputStream out = response.getOutputStream();

try {;
conn = getMySqlConnection();
} catch (Exception e) {
response.setContentType("text/html");
out.println("<html><head><title>Person Photo</title></head>");
out.println("<body><h1>Database Connection Problem.</h1></body></html>");
return;
}

try {
stmt = conn.createStatement();
rs = stmt.executeQuery(query);
if (rs.next()) {
photo = rs.getBlob(1);

} else {
response.setContentType("text/html");
out.println("<html><head><title>Person Photo</title></head>");
out.println("<body><h1>No photo found for id= 001 </h1></body></html>");
return;
}

response.setContentType("image/gif");
InputStream in = photo.getBinaryStream();
int length = (int) photo.length();

int bufferSize = 1024;
byte[] buffer = new byte[bufferSize];

while ((length = in.read(buffer)) != -1) {
System.out.println("writing " + length + " bytes");
out.write(buffer, 0, length);
}

in.close();
out.flush();
} catch (SQLException e) {
response.setContentType("text/html");
out.println("<html><head><title>Error: Person Photo</title></head>");
out.println("<body><h1>Error=" + e.getMessage() + "</h1></body></html>");
return;
} finally {
try {
rs.close();
stmt.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}

/**
* Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

}