How to fetch date from html form using jsp/servlet ( java ) and save it to database with column type date ??

Answered by Manish Kumar 

There are various ways of fetching Current Date and Time, 

  • Either you can use Javascript to fetch date/time from client side and send it to jsp/servlet page.
  • You can also fetch date/time from server side code.

Here is the example of fetching data from javascript and send it to jsp/servlet page using html form.


<h2> Getting Current Date From Html Page and sending Date to Jsp/Servlet using Html Form  </h2>

Enter name : <input type="text" name="name" /> <br/><br/>

Current date :<input type="text" id="mydate" name="date" />

<input type="submit" value="save" />



var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; 
var yyyy = today.getFullYear();

if(dd<10) {

if(mm<10) {

today = mm+'/'+dd+'/'+yyyy;

document.getElementById("mydate").value = today;