out implicit Object in jsp

By | March 21, 2020

Out Implicit object -:This is an instance of javax.servlet.jsp.JspWriter object. This object is used to send some data on response.Through this object, some data is written to the buffer and it is sent to the response.

Methods of Out Implicit Object -: There are some methods of using out implicit object

  • void print ()
  • void println()
  • void newLine(
  • void clear()
  • void clearBuffer()
  • void flush()
  • boolean isAutoFlush()
  • int getBufferSize()
  • int getRemaining()

Void print () -:This method is written to String for output without newline character (ln). For example

out.print(“Out Implicit Object - netnic”);

void println()-: String is written to output with this method newline character (ln). For example

<% 
    out.println("Hello netnic");
     out.println("Hello users");
  %>

void newLine()-: This method It adds newline to the output. For example of new line methods

<%  
   out.print("Hello netnic");  
   out.newLine();
     out.print("Hello users");
  %>

void clear() –: The clear () method is used to clear the buffer from the output. If the buffer is already flush then exception is thrown by this method. for example

<% 
  out.print("Hello netnic");
  out.clear();
 %>

void clearBuffer() -:The clearBuffer () method is used to clear the buffer from the output. If the buffer is already flush, the exception is not thrown by this method. For example ..

<%
 if (out.getBufferSize() != 0){     out.clearBuffer();
 } 
%>

void flush()-:The flush () method clears the buffer in the same way as the clear () method. But it writes data to output before flush it. For example

<% out.flush(); %>
 <jsp:forward page="myhtmlfile.html" />

boolean isAutoFlush()-:isAutoFlush () method used output buffer; Boolean value returns by checking whether it has been flushed automatically or not. for example..

<%@ page autoFlush="true" %>
<% out.print(out.isAutoFlush()); %>

int getBufferSize() -:This method returns the size of the output buffer to byte. For example

<%@ page buffer="5kb" %>
<% out.print("Buffer Size : " + out.getBufferSize()/1024 + "kb"); %>

int getRemaining()-: getRemaining () method returns empty output buffer to byte. For example ..

<%@ page buffer="5kb" %> 
<% out.print("Buffer Size : " + out.getRemaining()/1024 + "kb"); %>

Read More about JSP Implicit Object

Related topic of JSP 
JSP Tags 
JSP Implicit Object  
Definition of JSP

Leave a Reply

Your email address will not be published. Required fields are marked *