Till now you learned about the JSP syntax, now I will show you how to create a simple dynamic JSP page that prints the current date and time. So the following code accomplish this:
| <%@page
contentType="text/html" import="java.util.*"
%>
<!-- http://www.roseindia.net/jsp --> <html>
<tr>
</tr>
|
The heart of this example is Date() function of the java.util package which returns the current data and time.
In the JSP Declaratives
<%@page contentType="text/html" import="java.util.*" %>
we are importing the java.util package and following JSP Expression code
<%= new java.util.Date() %>
prints the current date on the page.
Execute the example.
Download the code
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: JSP date example View All Comments
Post your Comment