Monday, 3 December 2012

Simple JSP to display current date and time


Simple JSP Page 1

  1.  
  2. <html>
  3. <head>
  4. <title> Simple JSP page </title>
  5. </head>
  6. <body>
  7. <h3>Using Expression tag to display the result of the expression </h3>
  8. <p>
  9. The Current date and time = <%=new java.util.Date()%>
  10. </p>
  11. </body>
  12. </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