[an error occurred while processing this directive]

Date in JSP

                          

To print a Date in JSP firstly we are importing a class named java.util.Date of the package java.util. This package is imported in the jsp page so that the Date class and its properties can accessed in the JSP page. To import a package we need to use page directive inside which we will use its one of its attributes named import which is used for importing the class and package.

To print the current date we are using a expression directive in which we are creating a object of Date class. We have used toString() method to convert Date type to String.

 

The output of the program is given below:

 

 

<%@ page import ="java.util.Date" %>
<html>
	<head>
		<title>The current date is</title>
	</head>
		<body>
		<font size = 6 color = "#FF0000">current date is 
                 :<%= new Date().toString()%></font>
		</body>
</html>

The output of the program is given below:

Download this example:

                          

[an error occurred while processing this directive]