Enrique
Thanks for that , it worked....
Is there something similar you can do for the upload. I am using the
MultipartParser by Oreilly to do the upload, again i am having to create the
file on my server before I can save it as  binary data to the database.

thanking you in advance
Parag




Enrique Ortiz Torrent <[EMAIL PROTECTED]> on 10/04/2001
11:53:55

Please respond to "A mailing list for discussion about Sun Microsystem's Java
      Servlet API Technology." <[EMAIL PROTECTED]>

To:   [EMAIL PROTECTED]
cc:    (bcc: Parag Patwa/LON/WLB)

Subject:  Re: Displaying Images Dynamically using servlets



Hi

we develop a servlet in order to send directly the image to the browser,
here is the code :

     public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
     {

          ServletOutputStream html_out;
          java.lang.String query = SELECT IMAGE FROM DATABASE WHERE
IMAGENUMBER = " //replace with your select

          Connection OraConn =  conn.getConnection();
          Statement stmt = OraConn.createStatement();
          // select image from database
          ResultSet Result = stmt.executeQuery(query+" "+files);
          if (Result.next())
          {
               res.setContentType("image/jpeg");
               byte[] bytes = Result.getBytes(1);
               html_out = res.getOutputStream();
               html_out.write(bytes);
          }
     }

     if you want to use less memory, send in 4k blocks

     Statement stmt = conn.createStatement();
      // select image from database
     ResultSet Result = stmt.executeQuery(query+" "+files);
     ServletOutputStream out = res.getOutputStream();
     while (Result.next())
     {
         res.setContentType("image/jpeg");
         BufferedInputStream gifData = new
BufferedInputStream(Result.getBinaryStream(1));
          byte[] buf = new byte[4 * 1024];  // 4K buffer
          int len;
          while ((len = gifData.read(buf, 0, buf.length)) != -1)
            out.write(buf, 0, len);
      }

bye

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html











Diese Nachricht ist vertraulich. Sie ist ausschliesslich fuer
den im Adressfeld ausgewiesenen Adressaten bestimmt.
Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten
wir um eine kurze Nachricht. Jede unbefugte Weiterleitung
oder Fertigung einer Kopie ist unzulaessig. Da wir nicht die
Echtheit oder Vollstaendigkeit der in dieser Nachricht
enthaltenen Informationen garantieren koennen, schliessen wir
die rechtliche Verbindlichkeit der vorstehenden Erklaerungen
und Aeusserungen aus. Wir verweisen in diesem Zusammenhang
auch auf die  fuer die Bank geltenden Regelungen ueber die
Verbindlichkeit von Willenserklaerungen mit verpflichtendem
Inhalt, die in den bankueblichen Unterschriftenverzeichnissen
bekannt gemacht werden.

This message is confidential and may be privileged. It is
intended solely for the named  addressee. If you are not the
intended recipient please inform us. Any unauthorised
dissemination, distribution or copying hereof is prohibited.
As we cannot guarantee the  genuineness or completeness of
the information contained in this message, the statements
set forth above are not legally binding. In connection
therewith, we also refer to the governing regulations of
WestLB concerning signatory authority published in the
standard bank signature lists with regard to the legally
binding effect of statements made with the intent to
obligate WestLB.

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to