读取blob类型的具体代码自己写吧,不难,转到jsp页面可以在servlet中把图片对象放到request中,再从jsp中读出来

解决方案 »

  1.   

    kongxiangli(笑看红尘) 能不能说清楚一点?
    或连接的url?
      

  2.   

    (转)这是调用servlet的在页面上你这样调用<src="DownLoad?id=">就可以了import java.sql.*;import java.io.*;import java.util.*;import javax.servlet.*;import javax.servlet.http.*;public class DownLoad extends HttpServlet{    public DownLoad() {    }    public void doGet(HttpServletRequest request, HttpServletResponse response)        throws ServletException, IOException {        doPost(request,response);    }    public void doPost(HttpServletRequest request, HttpServletResponse response)        throws ServletException, IOException {        System.out.println("======DownLoad begin=====");        try{            Class.forName("oracle.jdbc.driver.OracleDriver");            Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@10.216.0.2:1521:ORCL","dms","dms");            Statement stmt=conn.createStatement();            String id=request.getParameter("id");            String sql="SELECT id, name, content FROM zyw_test where id='"+id+"'";            ResultSet rs=stmt.executeQuery(sql);            if(rs.next()){                Blob blob = rs.getBlob("content");                byte[] ab = blob.getBytes(1, (int)blob.length());                response.setContentType("image/jpeg");                ServletOutputStream op = response.getOutputStream();                op.write(ab);                op.flush();                op.close();            }        }catch(Exception ex){            ex.printStackTrace();        }        System.out.println("======DownLoad end=====");    }}
      

  3.   

    ServletOutputStream op = response.getOutputStream();
    后怎么在我的mapid.jsp显示这个图片啊?
      

  4.   

    jsp页面中加入<IMG height=99 src="servlet名称?id=<%=rs.getInt("id")%>" width=136></td>
    如上面的servlet名称:DownLoad