我正在尝试在我从数据库中提取的 jsp 页面上设置图片的大小。
我可以得到图像,但它填满了整个页面。
谁知道怎么设置图片的大小
谢谢
这是我在我的jsp上的代码:
<%
Blob image = null;  
byte[] imgData = null;  
Connection con;
String url="jdbc:mysql://localhost:3306/comshopDatabase";
String uName="root";
String pwd="";
Class.forName("com.mysql.jdbc.Driver").newInstance();
    con=DriverManager.getConnection(url,uName,pwd);
    String sql="Select image from images WHERE id = '1' ";
    PreparedStatement stmt=con.prepareStatement(sql);
    ResultSet resultset=stmt.executeQuery();
while(resultset.next())
{
    Blob bl = resultset.getBlob("image");
    byte[] pict = bl.getBytes(1,(int)bl.length());
    response.setContentType("image/jpg");
    OutputStream o = response.getOutputStream();
%>
<TABLE BORDER="1">
<TR>
<TH>picture</TH>
</TR>
<TR>
<td>Image</td><td><%o.write(pict);%></td>
    <%o.flush();
    o.close();%>
<TD> <%= resultset.getString(2) %> </TD>
<TD><%= resultset.getString(3) %></TD>
</TR>
</TABLE>
<BR>
<%
o.flush();
o.close();
}
%>