Home > Archive > PostgreSQL JDBC > November 2005 > create image "ON FLY"









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author create image "ON FLY"
sandrigo.lezcano@gmail.com

2005-11-09, 7:23 am

is posible???
from "byte[] buffer" (memory-base)
directly from PostgreSQL bytea field into browser???
withou write it in client or sever side... ???
like for ex.:

<!-- view.jsp -->
<html><body>
<img src="onflyimg.jsp?p_img=logo.jpg">
</body></html>

Connecting and retrieve image from db in onflyimg.jsp

Best regards
Att
--
____________________
___________________
sandrigo.lezcano@gmail.com ICQ:143590717
RUA INDEPENDENCIA 135 - BOA VISTA
CEP 06411-050 - Barueri/SP/Brazil
FONE 11 4198-1095
Vip-Systems Informatica
http://www.vip-systems.com.br
====================
===========

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Achilleus Mantzios

2005-11-09, 7:23 am

O sandrigo.lezcano@gmail.com έγραψε στις Nov 9, 2005 :

> is posible???
> from "byte[] buffer" (memory-base)
> directly from PostgreSQL bytea field into browser???
> withou write it in client or sever side... ???
> like for ex.:
>
> <!-- view.jsp -->
> <html><body>
> <img src="onflyimg.jsp?p_img=logo.jpg">
> </body></html>
>
> Connecting and retrieve image from db in onflyimg.jsp


Ofcourse.
Altho it might be possible to go with a jsp,
the "normal" binary (intented) way is with a servlet, like:

java.sql.Connection con = null;
OutputStream out = res.getOutputStream();
try {
PreparedStatement st=null;
st = con.prepareStatement("select mimetype,photo from
phots where id...");
ResultSet rs = st.executeQuery();
String mimetype = rs.getString(1);
ByteArrayOutputStrea
m baos = new ByteArrayOutputStrea
m();
byte[] img = rs.getBytes(2);
baos.write(img);
res. setContentType(mimet
ype);
baos.writeTo(out);
out.flush();
out.close();
}
catch (Exception e) {
throw new ServletException(e.getMessage());
}
finally {
try {
if (con != null) con.close();
}
catch (Exception e) {}
}



>
> Best regards
> Att
> --
> ____________________
___________________
> sandrigo.lezcano@gmail.com ICQ:143590717
> RUA INDEPENDENCIA 135 - BOA VISTA
> CEP 06411-050 - Barueri/SP/Brazil
> FONE 11 4198-1095
> Vip-Systems Informatica
> http://www.vip-systems.com.br
> ====================
===========
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>


--
-Achilleus


---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com