kotaravitez 0 Newbie Poster

hi Guys i'm new to ajax and jsp and i'm trying to execute some code . i'm not getting any error but i'm also not getting any result that i want i have placed code here pls make any correction if it has to be done thank you .

caller.jsp

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<html>
<head>
<script src="ajax.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page using AJAX</title>
</head>
<body>

<a onmousemove='showCustomer("")' href='#'>Server Date Time:</a>
<div id="ajax_res">Server Date Time will replace this text.</div>
</body>
</html>

ajax.js

function showCustomer()
{

if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("ajax_res").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","index.jsp",true);
xmlhttp.send();
}

index.jsp

<%@ page language="java" import="java.sql.*" %>
<%@ page session="true" %>
<%
  out.println("<p>");
  out.println("<table>"); out.println(" <strong>Search</strong></td><td>");
    %>
  <%=new java.util.Date()%>
 <%
Class.forName("com.mysql.jdbc.Driver");
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost/bib","root","root");
          Statement statement = connection.createStatement();

  String query3="select * from re where owner='"+session.getAttribute("e").toString()+"'";
  ResultSet r3 = statement.executeQuery(query3);
  int i=0;
  while(r3.next())
  {i++;
  }

out.println("<br>");
out.println("<table  width='782' border='1' cellpadding='0' cellspacing='0'>");
  out.println("<tr >");
    out.println("<td width='88'>Cite</td>");
    out.println("<td colspan='2'>");
    if(i>0)
    {
    out.println("<marquee ><b><a href="newreq.jsp">New Requests</a></b></marquee>");  
    }
    out.println("</td>");
  out.println("</tr>");
  String query="select * from publications where groupin like 'Public'";
  String searchby=request.getParameter("searchby");
String searchtxt = request.getParameter("searchtxt");

  ResultSet r = statement.executeQuery(query);
while(r.next())
{
out.println("  <tr ");
    out.println("<td height="38">"+r.getString(3)+"</td>");
   out.println("<td width='80' align='center'><a href='view.jsp?id="+r.getString(1)+">'>View </a></td>");
    if(r.getString(34).equals("unlock"))
    {
    out.print("<td width='100' align='center'><a href=edit.jsp?id="+r.getString(1)+"&id1="+r.getString(1)+">editing</a></td>");
    out.print("<td width='100' align='center'><a href=del.jsp?id="+r.getString(1)+"&id1="+r.getString(1)+">delteing</a></td>");
    }    
 out.println("</tr>");
 out.println("</table>");
 }
 %>