views:

45

answers:

2

I've just been given the task of updating a web page in an enterprise java web app to include the date in the page title.

Currently the web page is a static html file - what do i need to do to get the page title to be the current date in YYYY/MM/DD format? Sorry I have no idea where to start!

+1  A: 

You have two options:

  1. Update the page title with Javascript at the body onload event.
  2. Become this static HTML file into a JSP dinamic page.

Depending on your requirements, the first option will imply less changes. With the first option, you will take the browser date, with the second, you will use the server system date. This could be important if your application is to be accessed from different time zones.

Tomas Narros
In case of second variant try looking for <%= new java.util.Date() %> and appropriate formatting function. Besides you will need to import java.util.* on a jsp page.
den-javamaniac
+2  A: 
<script language="Javascript" type="text/javascript">
alert(document.title);
document.title = (new Date()) + " --- " + document.title;
</script>
Veerana Bhuya
Fixed code formatting and added type attribute
seanizer