I have 2 jsp page, i sent value from frist page to second page, but when i show value in input tag, the value have changed. What wrong with my coded? The first page:
<script>
$(function() {
$( "#datepicker" ).datepicker({
dateFormat: "yy/mm/dd",
showOn: "focus"
});
});
</script>
JSP:
<p>Date: <input type="text" id="datepicker" name="datepicker"></p>
And Servlet:
HttpSession s= request.getSession();
String olddate= (String)request.getParameter("datepicker");
s.setAttribute("DATE", olddate);
RequestDispatcher rd = request.getRequestDispatcher("nextpage.jsp");
The second Page JSP:
<%
HttpSession s= request.getSession();
DateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
String date = s.getAttribute("DATE").toString();
Date dateto = sdf.parse(date);
String newDateString = sdf.format(dateto);
%>
<p>Date From: <input type="text" id="datefrompicker" readonly="readonly">/p>
And Script:
$(document).ready(function(){
var date =<%=newDateString%>;
alert(dateto);
$( "#datefrompicker" ).datepicker( "setDate", date );
});
The first page value is 2015/11/01,the value in alert is 91.5909090909091, and input datefrompicker don't have any thing.
What am i do wrong?