Massimo Casella wrote:
>
> I have an image stored in a field of my database. I must show this image in
> a html page on Apache server.
> Can I show the images without write before the file in the server
> filesistem?
>
Your HTML page should include an image tag like this:
<img src=/servlets/getImage?foo=someInfo>
your getImage servlet than gets the image from the db and shows it on
the page.

the code in the getImage servlet should looke somethin like this:
     try{
        dbconnection = new
DbConnection("jdbc:mysql://foo-bar.com:3306/shopping", info);
        connection = dbconnection.getConnection();
        Statement smt = connection.createStatement();
        String Query = "select * from bar_table where num=" + someInfo;
        ResultSet rs = smt.executeQuery(Query);
        while (rs.next()){
           try{
             int BytesRead;
             byte[] buf = new byte[40000];
             InputStream dbin = rs.getBinaryStream(6);
             while (((BytesRead=dbin.read(buf)) != -1)){
               out.write(buf,0,BytesRead);
               out.write(BytesRead);
             }
             out.flush();
             rs.close();
             smt.close();
           } catch (IOException e) {
             out.println("oops!");
             ex.printStackTrace(out);
           }
        }

--
Sven E. van 't Veer, llm.
Departamento de Desenvolvimento
Brasil Informatica.
http://www.brvip.com.br

___________________________________________________________________________
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