Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Servlet not called on subsequent ajax requests

SumDoodFeb 27 2008 — edited Feb 27 2008
I'm using IE 6 and Jdev 10.1.2.17.

Once my servlet (PopulateQuestionDetails) is called with a specific number passed to it, it doesn’t get called again. For example, populateQuestionDetails() gets call the first time with (0001) passed to it. It runs fine and the servlet returns the correct data after hitting the database. If populateQuestionDetails() gets called again with (0001) passed to it, the servlet returns the same data that was retuned the first time the servlet was called with (0001) passed to it. It works fine the first time for (0002), (0003), etc with the same results on each consequent function call. I’ve peppered the code with system.out.printlns and alert(‘’)s. The javascript is called, but the servlet is never called again after the first call. Each subsequent call returns the same value as the first call. Funny thing is the problem occurs on half of our developer’s machines (and more importantly, the customer’s). Since it’s only on certain machines, I thought it might be some browser settings, but that all checked out.

Here is the basic javascript fuction:

function populateQuestionDetails(number,theForm)
{
if(number != 0)
{
var hand = function(str) {populateForm(str,theForm);}
var ajax = new Ajax();
ajax.doGet('servlet/PopulateQuestionDetails?number=' + number, hand);

}

}//end function populateQuestionDetails()


This function is called from a list of links on the page:
< -a- href="#" onclick=" populateQuestionDetails('0001',questionDetails.document.forms[0]);"> 0001 </-a->
<-a- href="#" onclick=";populateQuestionDetails('0002',questionDetails.document.forms[0]);"> 0002 </-a->

Etc.


(I stole the simple ajax class here: http://www.netregistry.com.au/news/articles/118/1/Build-Your-Own-AJAX-Web-Applications-Part-23/Page1.html )

I’ve got a workaround. If I pass a time stamp to the servlet, it works fine on all machines:

var thisDate = new Date();
var jsTime = thisDate.getDay() + thisDate.getHours() + thisDate.getMinutes() + ':' + thisDate.getSeconds();

ajax.doGet('servlet/PopulateQuestionDetails?number=' + number + '&time=' + jsTime, hand);


Seems to me this might be instantiating a new servlet object with each call from the js function (I honestly don’t know, being both a servlet and an ajax noob) and is therefore quite inefficient.

Questions:
Can I destroy the servlet via javascript somehow?
At the end of the doGet() method in the servlet, I call this.destroy(). How do I see if that’s working?
Why on earth would this be occurring on some machines and not others?
How can I check the app server (9iAS) to see if a new servlet object is being instantiated with each call?

Message was edited by:
user567664

Message was edited by:
user567664

Message was edited by:
user567664
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 26 2008
Added on Feb 27 2008
1 comment
567 views