Skip site navigation (1) Skip section navigation (2)

Re: create image "ON FLY"

From: Achilleus Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>
To: sandrigo(dot)lezcano(at)gmail(dot)com
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: create image "ON FLY"
Date: 2005-11-09 10:44:09
Message-ID: Pine.LNX.4.44.0511091237530.5689-100000@matrix.gatewaynet.com (view raw or flat)
Thread:
Lists: pgsql-jdbc
O sandrigo(dot)lezcano(at)gmail(dot)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(dot)lezcano(at)gmail(dot)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


In response to

pgsql-jdbc by date

Next:From: Oliver JowettDate: 2005-11-09 11:30:51
Subject: Re: use of OID.Unknown
Previous:From: sandrigo.lezcanoDate: 2005-11-09 10:38:20
Subject: create image "ON FLY"

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group