Sql 无法使用jsp从数据库中成功检索blob的其他信息?

Sql 无法使用jsp从数据库中成功检索blob的其他信息?,sql,jsp,blob,Sql,Jsp,Blob,我已经成功地通过.jsp程序将一个学生及其图像的详细信息插入到sql数据库中。问题是,当我通过另一个.jsp程序检索到存储的学生信息时,只显示图像,没有显示学生的其他信息 有人能帮我用代码检索存储的blob图像和其他信息并一起显示吗 我正在使用oracle数据库11g 它有一个名为studdetail的学生表。它有五列,第1列到第4列是varchar2,第五列是blob。我已经成功地通过html和jsp程序将值插入数据库。但当我检索回信息时,问题就出现了。它只显示图像,不显示其他信息 检索jsp

我已经成功地通过.jsp程序将一个学生及其图像的详细信息插入到sql数据库中。问题是,当我通过另一个.jsp程序检索到存储的学生信息时,只显示图像,没有显示学生的其他信息

有人能帮我用代码检索存储的blob图像和其他信息并一起显示吗

我正在使用oracle数据库11g

它有一个名为studdetail的学生表。它有五列,第1列到第4列是varchar2,第五列是blob。我已经成功地通过html和jsp程序将值插入数据库。但当我检索回信息时,问题就出现了。它只显示图像,不显示其他信息

检索jsp代码: show.jsp


JSP页面
学生证:
学生姓名:
学生支部代码
学生联络电话
学生形象

您错过了jsp中用于呈现图像的img标记

<%@page import="java.io.OutputStream"%>
<%@page import="java.sql.Blob"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.Connection"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%
       try{
                Class.forName("oracle.jdbc.OracleDriver");
                Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:db","xxxx","apple");



                PreparedStatement ps=con.prepareStatement("select * from studdetail");
                ResultSet rs=ps.executeQuery();
                while(rs.next()){ %>
                <table><tr><th>student id:</th><td><%=rs.getString(1) %></td></tr> 
                    <tr><th>student name:</th><td><%=rs.getString(2) %></td></tr>
                    <tr><th>student branch code</th><td><%=rs.getString(3) %></td></tr>
                    <tr><th>student contact number</th><td><%=rs.getString(4) %></td></tr>
                    <tr><th>students image</th><td>**<img src="
                <%
                    Blob bl=rs.getBlob(5);
                    byte[] image=bl.getBytes(1, (int)bl.length());
                    response.setContentType("image/bmp");
                    OutputStream o = response.getOutputStream();
                    o.write(image);
                    o.flush();
                    o.close();
             }
                %>"></img></td></tr>
                </table> 
                    <%
               con.close();
           }catch(Exception e){
          out.print(e);
          }

     %>
    </body>
</html>

JSP页面
学生证:
学生姓名:
学生支部代码
学生联络电话
学生形象**>

无论你在做什么,都是从数据库中检索图像并显示在网页中的一种粗糙方法。有更好的方法。我会将我的图像属性的源指定给一个servlet,该servlet将从数据库中检索图像块。

给我们看一些代码,告诉我们你使用的数据库。给我们看你的信息检索代码谢谢为了你的建议。我添加了img标签,但它仍然只是显示图像。。。
<%@page import="java.io.OutputStream"%>
<%@page import="java.sql.Blob"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.Connection"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%
       try{
                Class.forName("oracle.jdbc.OracleDriver");
                Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:db","xxxx","apple");



                PreparedStatement ps=con.prepareStatement("select * from studdetail");
                ResultSet rs=ps.executeQuery();
                while(rs.next()){ %>
                <table><tr><th>student id:</th><td><%=rs.getString(1) %></td></tr> 
                    <tr><th>student name:</th><td><%=rs.getString(2) %></td></tr>
                    <tr><th>student branch code</th><td><%=rs.getString(3) %></td></tr>
                    <tr><th>student contact number</th><td><%=rs.getString(4) %></td></tr>
                    <tr><th>students image</th><td>**<img src="
                <%
                    Blob bl=rs.getBlob(5);
                    byte[] image=bl.getBytes(1, (int)bl.length());
                    response.setContentType("image/bmp");
                    OutputStream o = response.getOutputStream();
                    o.write(image);
                    o.flush();
                    o.close();
             }
                %>"></img></td></tr>
                </table> 
                    <%
               con.close();
           }catch(Exception e){
          out.print(e);
          }

     %>
    </body>
</html>