简单的数据库实例 用JSP实现数据库图片的存储与显示实例[3]
用JSP实现数据库图片的存储与显示实例[3]
<%@ page contentType= text/;charset=gb %><%@ page import= java sql * %><%@ page import= java util * %><%@ page import= java text * %><%@ page import= java io * %><jsp:useBean id= conn scope= page class= dbconn DBResult /><%String path = request getContextPath();String basePath = request getScheme()+ :// +request getServerName()+ : +request getServerPort()+path+ / ;%><!DOCTYPE HTML PUBLIC //W C//DTD HTML Transitional//EN ><> <head> <base href= <%=basePath%> > <title>My JSP testimageout jsp starting page</title> <meta equiv= pragma content= no cache > <meta equiv= cache control content= no cache > <meta equiv= expires content= > <meta equiv= keywords content= keyword keyword keyword > <meta equiv= description content= This is my page > <! <link rel= stylesheet type= text/css href= styles css > > </head> <body> <% int id= Integer parseInt(request getParameter( picid )); String sql = select pic from p WHERE picid= +id; ResultSet rs=conn getResult(sql); while(rs next()) { ServletOutputStream sout = response getOutputStream(); //图片输出的输出流 InputStream in = rs getBinaryStream( ); byte b[] = new byte[ x a ]; for(int i = in read(b); i != ;) { sout write(b); //将缓冲区的输入输出到页面 in read(b); } sout flush(); //输入完毕 清除缓冲 sout close(); } %> </body></>
![简单的数据库实例 用JSP实现数据库图片的存储与显示实例[3]](http://img.zhputi.com/uploads/7711/7711f1fa00fb5b6dabcb75de4c5baf4331235.jpg)
lishixinzhi/Article/program/Java/JSP/201311/20707
相关文章
- 数据库是怎样囤积数据的
- 一个数据库有几个内模式 用JavaScript操作数据库
- odbc方式访问数据库 教你如何在MySQL数据库中直接储存图片
- 为了提高数据库的查询效率 建立JSP操作用以提高数据库访问效率[1]
- 数据库调用存储过程 用ASP调用SQL Server的视图和存储过程
- 一个数据库有几个内模式 JSP操作Access数据库
- 为了提高数据库的查询效率 如何建立JSP操作用以提高数据库访问效率
- sql存储过程入门 实例讲解JSP调用SQL Server的存储过程
- sql存储过程入门 JSP中调用SQL Server存储过程实例讲解
- 数据库常用的数据模型有 浅析JAVA常用JDBC连接数据库的方法总结
爱学记

微信收款码
支付宝收款码