0

データベースから JSP ページに画像を表示できません。問題がどこにあるのかまだわかりません。助けてください。

私のサーブレット:

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        DBConnection db = new DBConnection();
        Connection conn;
         try {
             conn =  db.getDbConnection();
            PreparedStatement ps = conn.prepareStatement("select stu_image from student_images_table where STU_REG_NO = ?");
            String id = request.getParameter("studentregno");
            ps.setString(1,id);
            ResultSet rs = ps.executeQuery();
            rs.next();
            Blob  b = rs.getBlob("stu_image");            
            response.setContentType("image/jpeg");
            response.setContentLength( (int) b.length());
           // response.setContentLength(10);
            InputStream is = b.getBinaryStream();
            OutputStream os = response.getOutputStream();
            byte buf[] = new byte[(int) b.length()];
            is.read(buf);
            os.write(buf);
            os.close();
        }
        catch(Exception ex) {
             System.out.println(ex.getMessage());
        }
    }

私のJSP:

<div id="bv_Image1" style="margin:0;padding:0;position:absolute;left:572px;top:31px;width:194px;height:162px;text-align:left;z-index:1;">
                        <img src="ProfileInquiryServlet" id="Image1" alt="" align="top" border="0" style="width:194px;height:162px;"></div>

私のディスプレイ:

ディスプレイに画像がありません

私は何が間違っている可能性がありますか?

編集: 私の Web.xml は巨大ですが、これは関連している可能性があります。

<servlet>
        <servlet-name>ProfileInquiryServlet</servlet-name>
        <servlet-class>com.kollega.controller.ProfileInquiryServlet</servlet-class>
    </servlet>
     <servlet-mapping>
        <servlet-name>ProfileInquiryServlet</servlet-name>
        <url-pattern>/ProfileInquiryServlet</url-pattern>
    </servlet-mapping>
4

1 に答える 1