title: retrieval of multiple images from the database using jsp-servlet
body: <p>Have a look at the following code snippet which I use to retrieve images from a database:</p>
  
  <pre><code>response.setContentType("image/gif");
  String url="jdbc:oracle:thin:@localhost:1521:xe";
  String username="xyz";
  String password="abc";
  
  Class.forName("oracle.jdbc.driver.OracleDriver");
  Connection conn=DriverManager.getConnection(url,username,password);
  String sql="Select name,description,image from pictures";
  PreparedStatement stmt=conn.prepareStatement(sql);
  ResultSet resultSet=stmt.executeQuery();
  ServletOutputStream sos=response.getOutputStream();
  
  while(resultSet.next()) {
      byte[] buffer=new byte[1];
  
      InputStream is=resultSet.getBinaryStream(3);
      while(is.read(buffer)&gt;0){
        sos.write(buffer);
  }
  sos.println();
  sos.flush();
  }
  
  sos.close();
  conn.close();
  </code></pre>
  
  <p>I am trying this code to display images which are retrieved from the database. This code is supposed to retrieve multiple images from multiple rows which are stored in the database. But this code displays a single image.</p>