<%@ 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。演示使用超声波传感器自动冲洗。
熟练掌握page指令的下面的属性:import、session、errorPage、isErrorPage、contentType、pageEncoding。 理解page指令的下面的属性:language、extends、buffer、autoFlush、info。
page [ language=”java” ] [ extends=”package.class” ] [ import=”{package.class | package.*}, …” ] [ session=”true | false” ] [ buffer=”none | 8kb | sizekb” ] [ ...
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...
<%@ page buffer="10240kb" autoFlush="false" %> 注: buffer:他的值可以是"none"或者一个数值。 指定处理JSP工作时的out处理网页出入内容 的模式。如果值为none,那么就不会有缓存,而所有的输出都是由servlet...
A、languageB、bufferC、importD、autoflush 4、JSP的结构由( B )组成(多选)。 A、指令B、注释C、脚本元素D、操作 5、以下选项中,那一项不是JSP指令( B )。 A、pageB、importC、includeD、taglib 6、下面哪...
A、language B、buffer C、import D、autoflush 4、JSP得结构由( B )组成(多选)。 A、指令 B、注释 C、脚本元素 D、操作 5、以下选项中,那一项不就是JSP指令( B )。 A、page B、import C、...
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、...
@ page autoFlush=”false” import=”java.awt.*,java.awt.image.*,com.sun.image.codec.jpeg.*,java.util.*”%><% String ImageStr = request.getParameter(“ID_Text”); if(ImageStr==null || ...
$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 $...
动态INCLUDE用jsp:include动作实现 <jsp:include page="included.jsp" flush="true" />它总是会检查所含文件中的变化,适合用于包含动态页面,并且可以带参数。 静态INCLUDE用include伪码实现,定不会检查所含文件的...
动态INCLUDE用jsp:include动作实现 <jsp:include page="included.jsp" flush="true" />它总是会检查所含文件中的变化,适合用于包含动态页面,并且可以带参数。 静态INCLUDE用include伪码实现,定不会检查所含文件...
命名管道的实际用例。... _writer.AutoFlush = true; } Thread.Sleep(1000); } } private static NamedPipeClientStream _client; private static StreamWriter _writer; private static Thread _thread; } }
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...