title: Display image from Database in JSP
body: <p>I want to display image in my JSP retrieved out of Database.
  Now, after a lot of research on internet, I figured out this code.</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
          &lt;title&gt;View Item&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;center&gt;
              &lt;h1&gt;View Item&lt;/h1&gt;
              &lt;%
              Connection con = DefaultConnection.establishSqlConnection();
              Statement stmt = con.createStatement();
              ResultSet rs = stmt.executeQuery("SELECT * FROM Items WHERE ItemCode='"+request.getParameter("itemCode")+"'");
              Blob image = rs.getBlob("ItemImage");
              InputStream imageInputStream = image.getBinaryStream();
              int bufferSize = 1024;
              byte[] buffer = new byte[bufferSize];
              int len=0;
              %&gt;
              &lt;form action="addItem.jsp" method="post"&gt;
                  &lt;table&gt;
                      &lt;tr&gt;&lt;%=rs.getInt("ItemCode")%&gt;&lt;/tr&gt;
                      &lt;tr&gt;&lt;%=rs.getString("ItemName")%&gt;&lt;/tr&gt;
                      &lt;tr&gt;&lt;%while ((len=imageInputStream.read(buffer)) != -1) {
                          out.write(buffer, 0, len);
                      }%&gt;&lt;/tr&gt;
                  &lt;/table&gt;
              &lt;/form&gt;
          &lt;/center&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Now my problem is that everywhere I saw, out.write() method is used with (byte[], int, int) arguments.
  But my NetBeans refuses to take those arguments. And API says that out.write() only supports (char[], int, int) arguments.
  I don't know if this way is right or not.</p>
  
  <p>Please tell if I'm doing something wrong or if there is some other absolute method of doing this.</p>