JSP

JSP Projects

JSP Project

Display the current Date and Time
Previous Home Next

 

In this page of the tutorials we are going to show how to display the current date and time in the JSP page. for display the current date we call to the Date() function which is imported from the java.util.Date.* package.

 java.util.Date() It is used to display the current date and time of the system on the JSP page

 
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<body>
<p>&nbsp;</p>
<div align="center">
<center>
<table><tr><td><font color=red>Current Date is:</font>
</td>
<td><font><%= new java.util.Date() %></font></td>
</tr>
<tr><td>This is the Example of the JSP</td></tr>

</table>
</center>
</div>
</body>
</html>

Previous Home Next