//3¡¢»ñÈ¡·þÎñÆ÷µÄÏìÓ¦²¢ÏÔʾʱ¼ä
???? }
???? xmlHttp.onreadystatechange=function()
?????? {
?????? if(xmlHttp.readyState==4){
?????????? document.myForm.time.value=xmlHttp.responseText;
???????? }
??????? }
//2¡¢·¢ËÍÇëÇó¸ø·þÎñÆ÷
??????? xmlHttp.open("GET","time",true);//timeÊÇServletµÄÃû×Ö£¬Ò²ÊÇÆäURLµØÖ·
??????? xmlHttp.send(null);
???????
???? }
?
?
?
? </script>
?
? <body>
??? <form? >
??? <table>
???????????? <tr>????????? <td>Óû§</td>
?????????????????????????? <td><input type="text"?? onblur?="AjaxFunction();"/></td>
????????????????????????????? //onblur?="AjaxFunction();À´¼¤»îjavascriptÖеĴúÂë
??????????????????? </tr>
???????????? <tr>????? <td>ʱ¼ä</td>
?????????????????????? <td><input type="text"?? /></td>
??????????????????? </tr>
????????? </table>??????????????????????????
??? </form><br>
? </body>
</html>
Servlet?? timeµÄÖ÷Òª´úÂëÊÇ£º
public void doGet(HttpServletRequest request, HttpServletResponse response)
???throws ServletException, IOException {
??response.setContentType("text/html;charset=UTF-8");
??PrintWriter out = response.getWriter();
?? Date d=new Date();
?? int? h=d.getHours();
?? int m=d.getMinutes();
?? int s=d.getSeconds();
?? System.out.println(d);
?? out.println(h+":"+m+":"+s);//ÕâÀï¾Í½«¸Õ´´½¨µÄʱ¼ä´«µÝ¸øÁËhtmlÒ³Ãæ
??out.flush();
??out.close();
?}
×îºó½á¹ûΪ£º
ÊäÈëÓû§Ãû£¬Êó±ê½¹µãÒÆ¿ª
£¬Êó±ê½¹µãÒÆ¿ª£¬´¥·¢Ê¼þºó£º
?
ÕâÑùÒ»¸öʵÀý¾ÍÍê³ÉÁË
¡¡