Advertisement
Methods | Description |
---|---|
void print(int i) | This method prints an int. |
void print(char c) | This method prints a char. |
void print(char []) | This method prints a char. |
void print(boolean b) | This method prints a boolean. |
void print(float f) | This method prints a float. |
void print(double d) | This method prints a double. |
void print(Object ob) | This method prints an object. |
void print(String str) | This method prints a String. |
void println(int i) | This method prints an int and terminates the line. |
void println(char c) | This method prints a char and terminates the line. |
void println(char []) | This method prints a char array and terminates the line. |
void println(boolean b) | This method prints a boolean and terminates the line. |
void println(float f) | This method prints a float and terminates the line. |
void println(double d) | This method prints a double and terminates the line. |
void println(Object ob) | This method prints an object and terminates the line. |
void println(String str) | This method prints a String and terminates the line. |
void print(int x) | This method prints an int and terminates the line. |
void clear() | This method clears the content of buffer. |
void flush() | This method flushes the buffer. |
<html>
<head>
<title>JSP inbuilt out object </title>
</head>
<body>
<h1>Using the JSP out object to print values.</H1>
<%
int i = 100;
char c = 'c';
short s = 10;
double d =2.5;
float f = 10.5f;
String str = "What a pleasant day it is!";
%>
Displaying value in an int : <% out.println(i); %> <br/>
Displaying value in a char : <% out.println(c); %> <br/>
Displaying value in a short : <% out.println(s); %> <br/>
Displaying value in a float : <% out.println(f); %> <br/>
Displaying value in a double: <% out.println(d); %> >% out.println("<br/>"); %>
Displaying value in a String : <% out.println(str); %>
</body>
</html>
Advertisement
<html>
<head>
<title>JspWriter vs PrintWriter </title>
</head>
<body>
< %@ page import ="java.io.PrintWriter" %>
<h1>Using the JSP out object to print values.</h1>
<% out.println("Hello from JSP out object"); %>
<br/>
<br/>
<h1>Using the PrintWriter object to print values.</h1>
<% PrintWriter pw = response.getWriter();
pw.println("Hello using PrintWriter"); %>
Thanks for reading and best wishes for your future.
</body>
</html>
<html>
<head>
<title>Using the out Object in a method. </title>
</head>
<body>
<h1>Using the out Object in a method.</h1>
<%!
javax.servlet.jsp.JspWriter out2;
void print() throws java.io.IOException
{
out2.println("Hello from JSP's out object!");
}
%>
<%
out2 = out;
print();
%>
</body>
</html>
<html>
<head>
<title>Using PrintWriter Object in a Method </title>
</head>
<body>
<h1>Using PrintWriter Object in a Method</h1>
<%@ page import ="java.io.PrintWriter" %>
<%!
PrintWriter pw2;
void print()
{
pw2.println("Hello from PrintWriter!");
}
%>
<%
PrintWriter pw = response.getWriter();
pw2= pw;
print();
%>
</body>
</html>
Advertisement
Advertisement
Please check our latest addition
C#, PYTHON and DJANGO
Advertisement