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);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] img = rs.getBytes(2);
baos.write(img);
res.setContentType(mimetype);
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