请帮忙,下面这些错误信息主要是那里引起的2008-6-7 23:41:20 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet servlet_image threw exception
java.lang.IllegalStateException: getOutputStream() has already been called for this response
at org.apache.catalina.connector.Response.getWriter(Response.java:610)
at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:198)
at image.doGet(image.java:46)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:856)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:565)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1509)
at java.lang.Thread.run(Thread.java:619)

解决方案 »

  1.   

    response 被重复定义一般用了开源的下载程序会出现这样的情况,导致的原因是 下载程序的jsp 有空格或回车
      

  2.   

    lz 是不是用了jspsmart 做下载程序了???检查一下
      

  3.   

    用jspsmart做上传,
    response 被重复定义 是在一起的吗
      

  4.   

    那问题就出在这了,你把那个jsp中   之前的空格和回车去掉<%%>之间的空格和回车去掉<%%>空格和回车去掉
    就应该没事了。
      

  5.   

    jspsmart 做的下载页面按照上面的方法,修改后就应该没事了
      

  6.   

    getOutputStream() has already been called for this response 在一个Action中,对于同一个response,
    response.getOutputStream()方法和response.getWriter()方法只能使用其中的一种。你一定是已经使用了response.getWriter()了。
      

  7.   


    <%
    //记录
    String  BBS_A="";
    String  bbs_img="";
    String  bbs_img_s="";
    try{
    out.print("相册图片上传成功!<br/>");
    out.print("<a href='photo.jsp?ids="+oid+"&amp;yx="+yx+"'>我的相册</a><br/>");
    out.print("<a href='index.jsp?yx="+yx+"'>社区首页</a><br/>");
    }catch (Exception e){
    }
    sqlbean.CloseSQL();
    %> 
    都是这样方法
    把<%%>里面的空格去掉还是<%%>外面的空格去掉
      

  8.   

    都没有用到response.getOutputStream()方法和response.getWriter()
      

  9.   

    上传代码是这样
    <%@ page contentType="text/html; charset=utf-8" language="java" import="com.jspsmart.upload.*" errorPage="" %>
    <%@ page import="java.io.*,java.awt.Image,java.awt.image.*,com.sun.image.codec.jpeg.*"%> 
    <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Cache-Control" content="max-age=0" forua="true" />
    <meta http-equiv="Cache-Control" content="no-cache" forua="true"/>
    <meta http-equiv="Cache-Control" content="must-revalidate" forua="true" />
    <title>图片上传</title>
    </head>
    <body bgcolor="#FF0000" background="">
    <table>
    <%
    java.text.SimpleDateFormat formatter_up = new java.text.SimpleDateFormat("yyyy-MM"); 
    java.util.Date currentTime_up = new java.util.Date();//得到当前系统时间 
    String str_date_up = formatter_up.format(currentTime_up); //将日期时间格式化 
    //创建目录
     java.io.File file_up = new java.io.File(""+request.getRealPath("/")+"/uploadfile/image/"+str_date_up+"/");
     boolean result_up = false;
     if(!file_up.exists()){
      //mkdirs方法可以创建多个目录
      result_up = file_up.mkdirs();
     }
    %>
    <%
    String  itid = request.getParameter("itid")==null?"":request.getParameter("itid");String title="",err="";
    SmartUpload mySmartUpload =new SmartUpload();
    long file_size_max=1024*1000;
    String fileName2="",ext="",testvar="";
    String url="/uploadfile/image/"+str_date_up+"/";      //应保证在根目录中有此目录的存在
    //初始化
    mySmartUpload.initialize(pageContext);
    try {//只允许上载此类文件
    mySmartUpload.setAllowedFilesList("jpg,gif,jpeg,png,JPG,GIF,JPEG,PNG,Jpeg,Jpg,Gif,Png");
    //上载文件 
    mySmartUpload.upload();
    } catch (Exception e){out.print("只允许上传jpg,gif,jpeg,png的文件!");
    return;
    }
    try{    com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(0);
        if (myFile.isMissing()){  
       
        out.print("先选择要上传的文件!");
    //请先选择要上传的文件
      return;
    }
        else{
          //String myFileName=myFile.getFileName(); //取得上载的文件的文件名
       ext= myFile.getFileExt();      //取得后缀名
       ext= ext.toLowerCase();
    if(!ext.equals("gif")&&!ext.equals("jpg")&&!ext.equals("png")&&!ext.equals("jpeg"))
    {out.print("不允许上传此类文件!");
    return;
    }
       long file_size=myFile.getSize();     //取得文件的大小  
    if(file_size<=0)
    {out.print("此类文件不存在!");
    return;
    }
       String saveurl="";
       if(file_size>file_size_max){        //上传文件大小不能超过
             out.print("上传不成功,文件太大!");
            //response.sendRedirect("photoup.jsp?err=1&itid="+itid+"");
    return;
       }
       else{  
        //更改文件名,取得当前上传时间的毫秒数值
        java.util.Calendar calendar = java.util.Calendar.getInstance();
        String filename = String.valueOf(calendar.getTimeInMillis()); 
        saveurl=request.getRealPath("/")+url;
        saveurl+=inttime+filename+"."+ext;          //保存路径
        myFile.saveAs(saveurl,mySmartUpload.SAVE_PHYSICAL);
        //out.print(filename);//-----------------------上传完成,开始生成缩略图-------------------------    
        java.io.File file = new java.io.File(saveurl);        //读入刚才上传的文件
        String newurl=request.getRealPath("/")+url+inttime+filename+"_s."+ext;  //新的缩略图保存地址
        Image src = javax.imageio.ImageIO.read(file);                     //构造Image对象
        float tagsize=50;
        int old_w=src.getWidth(null);                                     //得到源图宽
        int old_h=src.getHeight(null);   
        int new_w=0;
        int new_h=0;                            //得到源图长
        int tempsize;
        float tempdouble; 
        if(old_w>old_h){
         tempdouble=old_w/tagsize;
        }else{
         tempdouble=old_h/tagsize;
        }
        new_w=Math.round(old_w/tempdouble);
        new_h=Math.round(old_h/tempdouble);//计算新图长宽
        BufferedImage tag = new BufferedImage(new_w,new_h,BufferedImage.TYPE_INT_RGB);
        tag.getGraphics().drawImage(src,0,0,new_w,new_h,null);       //绘制缩小后的图
        FileOutputStream newimage=new FileOutputStream(newurl);          //输出到文件流
        JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(newimage);       
        encoder.encode(tag);                                               //近JPEG编码
         newimage.close();    
    }catch (Exception e){
    }
    %>
    </table>
    </body>
    </html>