`
jayjayjaylun
  • 浏览: 87158 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

page buffer autoFlush

    博客分类:
  • java
阅读更多
<%@ page language="java" pageEncoding="UTF-8"  autoFlush="false" buffer="10kb" contentType="text/html; charset=UTF-8"%><%
//jsp.error.page.badCombo
//autoFlush="false" buffer="none"
/***
从源码 可以看出
out 最后将自动清理缓存//所以要测试 autoFlush 和 buffer 将采用 out.getBufferSize() 和 out.clear() 结合测试.
} catch (Throwable t) {
    if (!(t instanceof SkipPageException)){
      out = _jspx_out;
      if (out != null && out.getBufferSize() != 0)
        try { out.clearBuffer(); } catch (java.io.IOException e) {}
      if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
    }
  } finally {
    _jspxFactory.releasePageContext(_jspx_page_context);
  }
}
}
       
*****/

/*
response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires",0);
response.flushBuffer();
*/
String name="";
for(int i = 0 ;i<1024*10; i++){
    name+="D";
}





//这里name 的长度为10240 个字符 刚好 等于buffer ="10kb" 大小 如果 此时 autoFlush="false"
//将抛出 //java.io.IOException: Error: JSP Buffer overflow (if autoFlush="false"  and  buffer  can't flush)
//note :  jsp 页面 一个回车换行 out('\n');out('\r') 输入2个字符.

System.out.println(" ===========name : " +name.length());
System.out.println(" =========== buffer size : " + out.getBufferSize());
System.out.println(" =========== out.isAutoFlush()  : " + out.isAutoFlush());
out.print(name);

//out.print("AAAAAAAAAAAAAAAAA");
//清除buffer 抛出异常 如果buffer 已经被清空
//out.clear();
//刷新buffer 输出到页面
out.flush();
//清除buffer 不会抛出异常
//out.clearBuffer();

out.print("<br/> BBBBBBBBBBBBBBBBB");
System.out.println(" =========== buffer size : " + out.getBufferSize());

//这里假设 可以 使得 out 最后不会调用out.clearBuffer();//可惜不可能
//  out = _jspx_out;  即使你这样设置了  tomcat 源码还是会帮你还原
/*
} catch (Throwable t) {
    if (!(t instanceof SkipPageException)){
      out = _jspx_out;
      if (out != null && out.getBufferSize() != 0)
        try { out.clearBuffer(); } catch (java.io.IOException e) {}
      if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
    }
  } finally {
    _jspxFactory.releasePageContext(_jspx_page_context);
  }
}
}
*/
out=null;
%><% //if out=null 后面不能出现空行 回车 out已经为空了...会有异常
%><%--
//out.isAutoFlush();
//out.close();

System.out.println(" =========== buffer size : " + response.getBufferSize());
Thread.sleep(3000);
/**
    public boolean isCommitted()
    Returns a boolean indicating if the response has been committed. A committed response has already had its status code and headers written.
**/

System.out.println(" =========== response is commited? /  : " + response.isCommitted());
//response.setBufferSize(1024*10);
//response.setBufferSize(10);
/**
public void flushBuffer()
                 throws java.io.IOException
    Forces any content in the buffer to be written to the client. A call to this method automatically commits the response, meaning the status code and headers will be written.
**/
//response.flushBuffer();
//response.resetBuffer();
//response.reset();

System.out.println(" =========== buffer size : " + response.getBufferSize());



/**
public void resetBuffer()
    Clears the content of the underlying buffer in the response without clearing headers or status code. If the response has been committed, this method throws an IllegalStateException.

public void reset()
    Clears any data that exists in the buffer as well as the status code and headers.
**/
    System.out.println(" =========================B");
    //response.sendRedirect("http://www.baidu.com");
   
    /*
        response.sendRedirect("whoami.jsp");
        Enter:
            http://192.168.1.14:8082/kathleen/a.jsp
        To:
            http://192.168.1.14:8082/whoami.jsp
           
        response.sendRedirect("whoami.jsp");
        To:
            http://192.168.1.14:8082/kathleen/whoami.jsp
    */
    //return;
    //if  you send this it will show IllegalStateException
    //because you had commit response.
    //response.sendRedirect("whoami.jsp");
    /**will not print in tomcat console**/
    System.out.println(" =========================A");
   
   
--%>
 



参考文档 :http://www.scribd.com/doc/34446565/JSP-Out-Object-Methods

分享到:
评论

相关推荐

    matlab开发-Autoflush

    matlab开发-Autoflush。演示使用超声波传感器自动冲洗。

    Java web课堂练习

    熟练掌握page指令的下面的属性:import、session、errorPage、isErrorPage、contentType、pageEncoding。 理解page指令的下面的属性:language、extends、buffer、autoFlush、info。

    JSP语法Page指令

    page [ language=”java” ] [ extends=”package.class” ] [ import=”{package.class | package.*}, …” ] [ session=”true | false” ] [ buffer=”none | 8kb | sizekb” ] [ ...

    Servlet与JSP核心编程第2版

    12.6 buffer和autoflush属性 12.7 info属性 12.8 errorpage和iserrorpage属性 12.9 isthreadsafe属性 12.10 extends属性 12.11 language属性 12.12 指令的xml语法 第13章 在jsp页面中包含文件和applet...

    IIS6缓冲区超过其配置限制

    &lt;%@ page buffer="10240kb" autoFlush="false" %&gt; 注: buffer:他的值可以是"none"或者一个数值。 指定处理JSP工作时的out处理网页出入内容 的模式。如果值为none,那么就不会有缓存,而所有的输出都是由servlet...

    Java-Web程序设计题库(1).doc

    A、languageB、bufferC、importD、autoflush 4、JSP的结构由( B )组成(多选)。 A、指令B、注释C、脚本元素D、操作 5、以下选项中,那一项不是JSP指令( B )。 A、pageB、importC、includeD、taglib 6、下面哪...

    Java-Web程序设计题库(2).doc

    A、language B、buffer C、import D、autoflush 4、JSP得结构由( B )组成(多选)。 A、指令 B、注释 C、脚本元素 D、操作 5、以下选项中,那一项不就是JSP指令( B )。 A、page B、import C、...

    Java-Web程序设计题库.doc

    A、language B、buffer C、import D、autoflush 4、JSP的结构由( B )组成(多选)。 A、指令 B、注释 C、脚本元素 D、操作 5、以下选项中,那一项不就是JSP指令( B )。 A、page B、import C、include D、taglib 6、...

    将JSP在内存生成的图片显示到页面

    @ page autoFlush=”false” import=”java.awt.*,java.awt.image.*,com.sun.image.codec.jpeg.*,java.util.*”%&gt;&lt;&#37; String ImageStr = request.getParameter(“ID_Text”); if(ImageStr==null || ...

    Using Perl For Web Programming.pdf

    $OUTPUT_AUTOFLUSH G $OUTPUT_FIELD_SEPARATOR G $OUTPUT_RECORD_SEPARATOR G $PERLDB G $PERL_VERSION G $POSTMATCH G $PREMATCH G $PROCESS_ID G $PROGRAM_NAME G $REAL_GROUP_ID G $REAL_USER_ID G $...

    java 面试题 总结

    动态INCLUDE用jsp:include动作实现 &lt;jsp:include page="included.jsp" flush="true" /&gt;它总是会检查所含文件中的变化,适合用于包含动态页面,并且可以带参数。 静态INCLUDE用include伪码实现,定不会检查所含文件的...

    超级有影响力霸气的Java面试题大全文档

     动态INCLUDE用jsp:include动作实现 &lt;jsp:include page="included.jsp" flush="true" /&gt;它总是会检查所含文件中的变化,适合用于包含动态页面,并且可以带参数。 静态INCLUDE用include伪码实现,定不会检查所含文件...

    c#使用命名管道实现打印调试

    命名管道的实际用例。... _writer.AutoFlush = true; } Thread.Sleep(1000); } } private static NamedPipeClientStream _client; private static StreamWriter _writer; private static Thread _thread; } }

    JSP动态网页制作基础培训教程源代码.rar

    10 sample3.jsp 第6章\ch6 访问SampleBean3示例(Page范围) 11 sample4.jsp 第6章\ch6 访问SampleBean3示例(Request范围) 12 sample5.jsp 第6章\ch6 13 sample6.jsp 第6章\ch6 访问SampleBean3示例(Session...

Global site tag (gtag.js) - Google Analytics