<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<script>
function adddate()
{
date=new Date();
var month = date.getMonth()+1;
var day = date.getDate();
var year = date.getFullYear();
if (document.getElementById('datetext').innertext =='')
{
document.getElementById('datetext').innertext = month + ' ' + day + ',' + year;
}
}
</script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body onload="adddate();">
<label id="datetext"></label>
<%--<input type="text" id="datetext">--%>
</body>
</html>
<%--this code is working for text box but not for label..why?--%>