易截截图软件、单文件、免安装、纯绿色、仅160KB

byte[]在jsp页面显示图片问题

HTML code:

<%@ page contentType="text/html; charset=GBK" language="java"%>

<%@ page import="java.io.*"%>

<html>

<body>

<form name="form" method="post">
<%
String bb = (String) request.getSession().getAttribute("content");//得到含有图片的字符串
byte[] date = bb.getBytes();
%>

<table>
<tr>
<td>
<%
response.setContentType("image/jpeg");
OutputStream toClient = response.getOutputStream();
InputStream in = new ByteArrayInputStream(date);
int len;
byte[] buf = new byte[1024];
while ((len = in.read(buf, 0, 1024)) != -1) {
toClient.write(buf, 0, len);
}
toClient.close();
%>
</td>

</tr>
</table>
</form>

</body>
</html>



在这个jsp页面中,我从session中将字符串图片取出来并转化为byte[]数据显示在jsp页面中。现在字符串图片数据已经取出来,可显示图片的时候报这个错误:
ERROR 2009-10-13 09:55:47 org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/BOSP].[jsp] Servlet.service() for servlet jsp threw exception
java.lang.IllegalStateException: getOutputStream() has already been c


相关问答:

jsp链接sql2000的疑问?



type Exception report


message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jas ......

jsp中显示菜单(递归)

问题描述:

    例如我要显示的内容如下所示

一级目录1
    一级目录1子类1
        子类1
    一级目录1子类2
      ......

关于AJAX和JSP的一些小问题~ - Java / Web 开发

我JSP的页面是:
<%@ page language="java" contentType="text/html; charset=gb2312"
  %>
<script>
function Save(){
xmlHttp=GetXmlHttpObject()
if(xmlHttp==nul ......

php跟jsp之间session共享的问题 - Java / Web 开发

最近一个项目中遇到一个问题:在原有的一套系统中(php开发)添加一些小功能(jsp开发),原来用户系统都是php开发的,我如何在jsp开发的功能中做到用户信息session同步呢? 有人是否有做过类以项目,想听听大家的看法
......

jsp的问题 - Java / Web 开发

大家好,我在JSP的初学者,在编程中遇到了一个问题:
<jsp:useBean id="accountBiz" class="bank.AccountBiz" 
scope="application">
这个标签中application和sessi ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号