JSP out object

What is a buffer
Buffer: Buffer, the so-called buffer is an area of ​​memory used to store temporary data.
 
Two out objects
The out object is an instance of the JspWrite class, which is a commonly used object for outputting content to the browser.
 
Three common methods


 
 
Four examples
<%@ page language = "java" import = "java.util.*" contentType = "text/html; charset=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 > My JSP 'index.jsp' starting page </ 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 >
    < h1 > outbuilt-in object </ h1 >
    <%
       out.println( "<h2>Silent Night Thoughts</h2>" );
       out.println( "Moonlight in front of the bed<br>" );
       out.println( "Suspected to be frost on the ground<br>" );
       out.flush();
       //out.clear();//An exception will be thrown here.
       out.clearBuffer(); //No exception will be thrown here.
       out.println( "Look up at the moon<br>" );
       out.println( "Looking down and thinking about my hometown<br>" );
   
    %>
        Buffer size: <%= out.getBufferSize() %> byte < br >
        Buffer remaining size: <%= out.getRemaining() %> byte < br >
       Whether to automatically flush the buffer: <%= out.isAutoFlush() %> < BR >    
  </ body >
</ html >
 
Five running results

 



 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326819127&siteId=291194637