Monday, 3 December 2012

Simple JSP to display current date and time


Simple JSP Page 1


<html>
<head>
<title> Simple JSP page </title>
</head>
<body>
<h3>Using Expression tag to display the result of the expression </h3>
<p>
The Current date and time = <%=new java.util.Date()%>
</p>
</body>
</html>


Description:

  • Insert opening and closing  <HTML>, <HEAD>, and <BODY> tags.A JSP page must  have valid syntax.
  • Type <%= %> at the position where the date must be displayed.Java Code will be exxecuted only if it is placed within delimiters.
  • Type java.util.Date() between <%= and  %>.This will create a date object that stores the current date and time.


****************************Output*************************************

Using Expression tag to display the result of the expression

The Current date and time = Mon Dec 03 15:17:24 CST 2012

************************************************************************

No comments:

Post a Comment