Tuesday, 11 November 2014

JSP out implicit object

The JSP implicit out object is an instance of the javax.servlet.jsp.JspWriter class
The out implicit object is used to write the output content.
In case of servlet,we have to declare the out object as
PrintWriter out=response.getWriter(); 
out.print(new Date());
But in jsp
We can directly use it for writing the output content as
Current time is <% out.print(new Date()); %>
jsp1.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>out Example</title>
</head>
<body>
Current time is <% out.print(new java.util.Date()); %>
</body>
</html>
output