惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Jina AI
Jina AI
Forbes - Security
Forbes - Security
雷峰网
雷峰网
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
V
Visual Studio Blog
月光博客
月光博客
博客园 - Franky
有赞技术团队
有赞技术团队
宝玉的分享
宝玉的分享
博客园 - 三生石上(FineUI控件)
酷 壳 – CoolShell
酷 壳 – CoolShell
Apple Machine Learning Research
Apple Machine Learning Research
The Register - Security
The Register - Security
S
SegmentFault 最新的问题
博客园 - 司徒正美
P
Proofpoint News Feed
Know Your Adversary
Know Your Adversary
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
A
Arctic Wolf
Cyberwarzone
Cyberwarzone
Simon Willison's Weblog
Simon Willison's Weblog
U
Unit 42
P
Proofpoint News Feed
Scott Helme
Scott Helme
MyScale Blog
MyScale Blog
T
Tenable Blog
Hugging Face - Blog
Hugging Face - Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
小众软件
小众软件
C
CERT Recently Published Vulnerability Notes
P
Palo Alto Networks Blog
V
V2EX
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Tailwind CSS Blog
V
Vulnerabilities – Threatpost
Latest news
Latest news
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
I
Intezer
Microsoft Azure Blog
Microsoft Azure Blog
爱范儿
爱范儿
博客园 - 【当耐特】
B
Blog RSS Feed
N
Netflix TechBlog - Medium
Recent Announcements
Recent Announcements
NISL@THU
NISL@THU
C
Cisco Blogs
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Schneier on Security

博客园 - 轻松逍遥子

Oracle 9i的数据类型 javascript事件查询综合 - 轻松逍遥子 - 博客园 用正则表达式检验是否输入日期时间是有效&&&&&& execCommand指令集 用net命令使局域网文件批量同步更新 无分]遍历表单 - 轻松逍遥子 - 博客园 设计有复杂客户端Script的服务器控件 [WEB开发] 基于XMLHTTP的简单实例 xmlhttp组件获取远程文件并筛选出目标数据 - 轻松逍遥子 - 博客园 XMLHTTP Get HTML页面时的中文乱码之完全客户端Script解决方案 XMLHTTP---介绍(自动抓网页内容) - 轻松逍遥子 - 博客园 Spring与EJB3.0的比较 手把手配置Hibernate环境 运用Jakarta Struts的七大实战心法 struts+spring+hibernate之间的关系与差别(ZT)- - JBuilder2005+JBOSS+Oracle9i环境配置[zt]- - 无限级目录树最优算法的新研究 解决JBuilder在中文系统中光标错位的问题(10.18最新,适合JB2005) servlet实现从oracle数据库的blob字段中读出文件并显示 关于下载的一点心得!!(如何弹出对话框!)
不经过临时文件,直接从BLOB字段,下载数据显示图片!
轻松逍遥子 · 2005-08-16 · via 博客园 - 轻松逍遥子

看下面的这个函数:
public void createImage(ServletRequest req, ServletResponse res,Chart chart)throws IOException
{

res.setContentType("image/jpeg");    
ChartUtilities.writeChartAsJPEG(res.getOutputStream(),
100,chart.getChart(),chart.getWidth(),chart.getHeight(),null);
}

用第一钟,比较好
下面是程序,你只要在web.xml中配个servlet就可以了。
import java.sql.*;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class DownLoad extends HttpServlet{
    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","test","test");
            Statement stmt=conn.createStatement();
            String id=request.getParameter("id");
            String sql="SELECT id, name, content FROM 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=====");
    }
}
以下是调用,其中tempChart是你生成的chart对象
<%
new com.chart.CreateChartImage().createImage(request,response,tempChart);

%>

--------两个jsp---------------

--------------------主-----------------------
<table width="100%" >
<tr>
<td align="center"><img  src="item_pic.jsp?ITEM_ID=<%=item_id%>&PIC_NUM=<%=pic_num%>">
</td>
</tr>
</table>
----------------------------------------item_pic.jsp--------------------------------------<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%  
     Connection conn = null;
 Statement stmt=null;
 ResultSet set=null;
     try{
String item_id=request.getParameter("ITEM_ID");
String pic_num=request.getParameter("PIC_NUM");
String sql="select PIC from ITEM_PIC WHERE ITEM_ID ="+item_id+" and  PIC_NUM = "+pic_num;
   conn =getConnection();
        stmt = conn.createStatement(); 
set = stmt.executeQuery(sql);
if(set.next()){
InputStream in = set.getBinaryStream("PIC");
response.reset();
response.setContentType("image/jpeg");
byte[] b = new byte[1024];
int len;
while((len=in.read(b))!=-1){
response.getOutputStream().write(b);
}
in.close();
}
 }catch(Exception e){
 }finally{
try{
if(set!=null)
set.close();
}catch(java.sql.SQLException se){
}
try{
if(stmt!=null)
stmt.close();
}catch(java.sql.SQLException se){
}
   try{
   if(conn != null )
conn.close();
   }catch(java.sql.SQLException se){
   }
}
%>