1. JSP Sample

1. JSP-Sample

HTML-Teil

    <script type="text/javascript">
       // <![CDATA[
      "use strict";

      var xmlhttp = new XMLHttpRequest();
       // verbinde XMLHttpRequest mit der "Event-Methode"
      xmlhttp.onreadystatechange = readajax;

      function  testajax( form ) {
        "use strict";
          // Aufruf 
         xmlhttp.open("GET", "TestAjax01.php?parameter=wert");
         xmlhttp.send(null);
      }

       function readajax() {
         "use strict";
         var elementajax = document.getElementById("ajax");
         if (xmlhttp.readyState == 4) {
           elementajax.innerHTML = xmlhttp.responseText;
         }
         else {
           alert(xmlhttp.readyState);
         }
       }

      // ]]>
    </script>

  </head>

<body>
  <form>
    <input type="button" value="Send" onclick="testajax(this.form)"/>
  </form>
   <div id="ajax"> </div>
</body>
</html>
</div>

JSP-Teil


<%@ 
  page import = "java.util.* " 
%>

<%@ 
  page import = "java.text.* " 
%>

<%

  SimpleDateFormat date=new SimpleDateFormat("HH:mm:ss");
  String time=date.format(new Date());
  out.println(time);
 
%>



Druckbare Version

2. PHP Sample
2. JSP Sample