Exibir BLOB (imagem) por meio do JSP
Eu tenho um código para mostrar um gráfico de funcionários.
Os dados (nome, telefone, foto, etc.) são armazenados no SQLServer e exibidos por meio do JSP. Mostrar os dados está ok, exceto a imagem .jpg (armazenada na coluna IMAGE = BLOB).
A propósito, eu já tenho a imagem exibida (veja o código abaixo), mas eu não sei como colocá-la na área definida em um .css (veja o código abaixo também), já que a imagem passou pelo resultSet é carregado em toda a página no navegador.
Alguém sabe como posso "enquadrar" a imagem?
<%
Connection con = FactoryConnection_SQL_SERVER.getConnection("empCHART");
Statement stSuper = con.createStatement();
Statement stSetor = con.createStatement();
Blob image = null;
byte[] imgData = null;
ResultSet rsSuper = stSuper.executeQuery("SELECT * FROM funChart WHERE dept = 'myDept'");
if (rsSuper.next()) {
image = rsSuper.getBlob(12);
imgData = image.getBytes(1, (int) image.length());
response.setContentType("image/gif");
OutputStream o = response.getOutputStream();
//o.write(imgData); // even here we got the same as below.
//o.flush();
//o.close();
--[...]
<table style="margin: 0px; margin-top: 15px;">
<tr>
<td id="photo">
<img title="<%=rsSuper.getString("empName").trim()%>" src="<%= o.wite(imageData); o.flush(); o.close(); %>" />
</td>
</td>
<td id="empData">
<h3><%=rsSuper.getString("empName")%></h3>
<p><%=rsSuper.getString("Position")%></p>
<p>Id:<br/><%=rsSuper.getString("id")%></p>
<p>Phone:<br/><%=rsSuper.getString("Phone")%></p>
<p>E-Mail:<br/><%=rsSuper.getString("Email")%></p>
</td>
</table>
E aqui está o fragmento que deveria enquadrar a imagem:
#photo
{
padding: 0px;
vertical-align: middle;
text-align: center;
width: 170px;
height: 220px;
}
Desde já, obrigado !