This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes problem in refreshing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "problem in refreshing" Watch "problem in refreshing" New topic

problem in refreshing

priya pratheepp
Ranch Hand

Joined: Apr 02, 2008
Posts: 59

for refreshing the page I am using ajax .When i call it in html it is working.when i call it in jsp i am not getting result.I can't able to understand where is the problem please help.

line where calling the ajax is

out.println("<Select name=\"staff_grade\" onChange=\"showCustomer(this.value)\" >");


var xmlHttp

function showCustomer(str)
if (xmlHttp==null)
alert ("Your browser does not support AJAX!");
var url="report_to.jsp";

function stateChanged()
if (xmlHttp.readyState==4)

function GetXmlHttpObject()
var xmlHttp=null;
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
catch (e)
// Internet Explorer
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
catch (e)
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
return xmlHttp;

JSP PROGRAM IS report_to.jsp

<%@ page language="java" import="*,java.text.*,java.sql.*,java.util.*,gsis.*"%>


String reportTO= request.getParameter("q");
int reportTOI=Integer.parseInt(reportTO);

while(reportTOI > 0)

}catch(Exception e)

out.println("Problem in connection" + e.toString());



please help...urgent one

thanks in advance
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15376
  • GET is made to cache, post is not. So the call is going what http get requests are designed to do.
  • You are not setting no cache headers on your jsp page.
  • open should come before onreadystatechange
  • You are not checking the status code of 200
  • you can set the is moified header

  • As Bear and I always say. It is better to use a library for Ajax code than to write your own. There are tons of quirks in the Ajax code that you are not taking into account. I only listed a couple above, but there are a lot more.

    priya pratheepp
    Ranch Hand

    Joined: Apr 02, 2008
    Posts: 59
    Hi Eric,

    Thank you for the valuable suggestions.

    I am new to AJAX and I must use this to refresh my page today.

    *****library for Ajax code ****

    Can you tell me any library code to my purpose.When I select a value in select button then next select button should display the data corresponds to the previous selected item.

    Once again thanks
    Bear Bibeault
    Author and ninkuma

    Joined: Jan 10, 2002
    Posts: 60794

    I generally recommend one of Prototype or jQuery as general-purpose JavaScript libraries with good Ajax APIs. These days, I'm using jQuery personally.

    [Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
    I agree. Here's the link:
    subject: problem in refreshing
    Similar Threads
    How to display value in combo box using AJAX
    Regading getElementById
    Can AJAX helps me to do that
    Using AJAX in Struts.... need steps to Implement..
    problem with sending # character through ajax