Java读取数据库Blob对象返回到JSP页面和getOutputStream() has already been called for this response异常处理
来源:互联网 发布:sqlserver 优势 编辑:程序博客网 时间:2024/06/05 09:32
<%@page import="java.sql.Blob"%><%@page import="java.sql.ResultSet"%><%@page import="java.sql.CallableStatement"%><%@page import="java.io.BufferedOutputStream"%><%@page import="java.io.FileInputStream"%><%@page import="java.io.OutputStream"%><%@page import="java.io.InputStream"%><%@page import="java.io.File"%><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Insert title here</title></head><body><%//CallableStatement cs = conn.prepareCall("call `xxx`.`xxxx`();");//ResultSet rs = cs.executeQuery(); //if (rs.next()) { //Blob b = rs.getBlob("magazine"); //long size = b.length(); //byte[] bs = b.getBytes(1, (int)size); //} //后面差不多,主要是byte的来源变了File file = new File("C:\\Begin Google Map.pdf");//也可以从文件读取long length = file.length();InputStream stream = new FileInputStream(file);BufferedOutputStream os = new BufferedOutputStream(response.getOutputStream());//用Buffered包裹效率高//OutputStream os = response.getOutputStream();byte[] buf=new byte[(int)length];response.setContentType("application/pdf");try { int n; while ((n = stream.read(buf)) != -1) os.write(buf, 0, n);//这里要这么写,表示读多少写多少} catch (Exception e) {e.printStackTrace();}os.flush();os.close();out.clear();//这两句话一定要加上,否则报getOutputStream() has already been called for this response异常out = pageContext.pushBody();%></body></html>
- Java读取数据库Blob对象返回到JSP页面和getOutputStream() has already been called for this response异常处理
- getOutputStream() has already been called for this response 异常处理
- getOutputStream() has already been called for this response异常处理
- JAVA异常 getOutputStream() has already been called for this response
- jsp出现getOutputStream() has already been called for this response异常的原因和解决方法
- jsp出现getOutputStream() has already been called for this response异常的原因和解决方法
- jsp出现getOutputStream() has already been called for this response异常的原因和解决方法
- jsp出现getOutputStream() has already been called for this response异常的原因和解决方法
- jsp出现getOutputStream() has already been called for this response异常的原因和解决方法
- 转异常getOutputStream() has already been called for this response
- getOutputStream() has already been called for this response异常
- 异常:getOutputStream() has already been called for this response
- 异常 getOutputStream() has already been called for this response
- getOutputStream() has already been called for this response异常
- 抛出异常getOutputStream() has already been called for this response
- jsp图片验证码实现及getOutputStream() has already been called for this response异常
- jsp图片验证码实现及getOutputStream() has already been called for this response异常
- jsp图片验证码实现及getOutputStream() has already been called for this response异常
- 使用internal(com.android.internal)和hidden(@hide)APIs – Part 2
- visio 如何反向连接数据库生成er图( 即根据数据库自动生成ER图 )
- android实现九宫格效果
- 问题解决之--无法识别的属性“targetFramework”。请注意属性名称区分大小写。
- Java MD5
- Java读取数据库Blob对象返回到JSP页面和getOutputStream() has already been called for this response异常处理
- 常见的链表题目
- some special cases of "extern" in C
- 累加1+2+...+10的4种写法
- Android Property System
- 日语学习--- 公司介绍写法
- 使用internal(com.android.internal)和hidden(@hide)APIs – Part 3
- Cannot create a server using the selected type
- android adb command