1.JSP内置对象的概念:JSP的内置对象时Web容器所创建的一组对象,不使用new关键字就可以使用的内置对象
2.JSP九大内置对象内置对象:out ,request ,response ,session ,application ,page , pageContent ,exception ,config等,前五个是经常使用的内置对象
3.缓冲区:Buffer 就是内存中一块区域,用来临时保存数据
4.out对象:是JspWriter类的实例,是向客户端输出内容常用的对象,(客户端大多数是指浏览器)
常用的方法:
out的例子:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>out内置对象</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body> <% out.println("<h2>静夜思</h2>"); out.println("床前明月光<br/>"); out.println("疑是地上霜<br/>"); out.flush(); //out.clear();//这里会抛出异常,一旦抛出异常,后面的则不会被打印 //out.clearBuffer();//这里不会抛出异常 out.println("举头望明月<br/>"); out.println("低头思故乡<br/>"); %> 缓冲区大小: <%=out.getBufferSize() %>byte<br/> 缓冲区剩余:<%=out.getRemaining() %>byte<br/> 是否自动清除缓冲区:<%=out.isAutoFlush() %><br/> </body> </html>