Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
JSP date example 
 

JSP date example JSP Date Example 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"

 

JSP date example

                          

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>
<body>
<p>
&nbsp;</p>
<div align=
"center">
<center>
<table border=
"0" cellpadding="0" cellspacing
=
"0" width="460" bgcolor="#EEFFCA">

<tr>
<td width=
"100%"><font size="6" color
=
"#008000">&nbsp;Date Example</font></td>

</tr>
<tr>
<td width=
"100%"><b>&nbsp;Current Date 
and time is:&nbsp;
<font color="#FF0000">


<%= new java.util.Date() %>
</font></b></td>
</tr>
</table>
</center>
</div>

</body>
</html>

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

                          

» View all related tutorials
Related Tags: jsp div io sed vi rmi number visio opera ai js to division modulus e main use ul pe in

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

18 comments so far (
post your own) View All Comments Latest 10 Comments:

Hi i just went through the examples of the site and they are execellent and very nicely explained.

Thank u

Ankit

Posted by Ankit Shah on Friday, 12.5.08 @ 01:36am | #82427

Hi Srinivasan: you have to put your file abc.jsp into the folder webapps if you are using Tomcat. Then you have to open your browser and in the addres bar write: http://localhost:8080/abc.jsp
Hope it's what you are asking for.
Regards
Crista

Posted by Crista on Wednesday, 06.11.08 @ 04:02am | #62987

i have one form, in that i have two text box which is used to get only hours and minutes like starting and ending time s of classes(9:30 to 10:30)
after receiving that value from the form i want store it in oracle table...
by using condition i want to retrive the record set deatils which is equal to 9:30 to 10:30.....

Posted by vasanthi on Monday, 03.24.08 @ 18:02pm | #54161

i want to retrieve date fields from the database in jsp with some user condition ie
i get input from_date and to_date from the user , then i want to retrieve the records present in my database with that given dates.
plz...../

Posted by pavithra on Wednesday, 02.27.08 @ 21:01pm | #50324

how can i create a web project using jsp in myeclipse........please inform me

Posted by Ramanuja Reddy on Saturday, 02.2.08 @ 10:59am | #46950

i am really thanks this web site
this one of the devlober best site very nice roseindia.net

Posted by prakasam on Friday, 01.25.08 @ 12:34pm | #46106

Your web site is absolutely marvelous....... it has got most of the fundamentals right and its very informative....... im a employee of Ness Technologies, Banglore n am a very good reader of the articles in ur web......

Thank u......
Regards,
Abdullah khan

Posted by Abdullah khan on Tuesday, 10.23.07 @ 09:39am | #34601

I want to get the time only.
How i want to write the program.
This program show all date month year time

Posted by selestin on Tuesday, 10.16.07 @ 14:56pm | #34197

if any body ask the exact definition of web server then wat to answer can any body tell me??????/

Posted by neha on Monday, 09.17.07 @ 16:03pm | #27118

hi while compliling the same date.jsp ,im getting error for generated servlet saying that cannot access the java.lang.object bad class file with (JRE path)
along with version saying that actual version is 48.0 and file is 49.0 either select the correct subdirectory or path .

please provide me solution .

Posted by mukesh on Monday, 08.27.07 @ 11:33am | #24236

Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.