Hi there,
I need to hit few list of sites from my application and find the response time of those site and sort them (which ever is opening first will sit at the top). I have done the same using java (server side). Now my requirement is do in the client side (AJAX possibly). I’m having two challenges. Below is what I have done so far, -
-
<script>
-
function call()
-
{
-
var d = new Date();
-
var xmlHttp;
-
try
-
{ // Firefox, Opera 8.0+, Safari
-
xmlHttp=new XMLHttpRequest();
-
}
-
catch (e)
-
{ // Internet Explorer
-
try
-
{
-
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
-
}
-
catch (e)
-
{
-
try
-
{
-
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
-
}
-
catch (e)
-
{
-
alert("Your browser does not support AJAX!");
-
return false;
-
}
-
}
-
}
-
xmlHttp.onreadystatechange=function()
-
{
-
if(xmlHttp.readyState==4)
-
{
-
alert(xmlHttp.responseText);
-
/* if(xmlHttp.responseText != undefined);
-
var res_min = d.getMinutes();
-
var res_sec = d.getSeconds();
-
var res_time = res_min*60+res_sec;
-
alert(res_time);
-
response_time=res_time-req_time*/
-
}
-
}
-
-
var req_min = d.getMinutes();
-
var req_sec = d.getSeconds();
-
var req_time = req_min*60+req_sec;
-
alert(req_time);
-
-
var url="http://localhost:8080/";
-
// url=url+"?q="+q;
-
xmlHttp.open("GET",url,true);
-
xmlHttp.send();
-
-
}
-
</script>
Challenge 1: I’m using “var url="http://localhost:8080/";” because I’m unable to use urls of google, yahoo or bytes here. Getting “Access Denied” error. Cross domain scripting is not possible here.
So, any clues on cross domain scripting/proxy?? Challenge 2: “if(xmlHttp.rea dyState==4)”. Inside this function I get the responseText. Now all I want is, a way to find whether the url is responding or not (getting opened or not).
Reason: only if I know whether the site is accessible, (and if yes, how long?) I can proceed (since I’m calculating the response time here… like I have mentioned on the top).
I believe I have briefed my issue as much as possible. If it’s still not complete, kindly tell me on which part should I further explain. Thank you.
fREDDIE
10 5249 acoder 16,027
Recognized Expert Moderator MVP
If you've already solved this with Java on the server-side, call that script instead passing the URL and the response should be the response time. From that, you can sort the list.
Hi acoder,
If you've already solved this with Java on the server-side, call that script instead passing the URL and the response should be the response time. From that, you can sort the list.
:)... The thing is, I want to finish off everthing in the client side in this regards. This must no way be a concern/workof for a java class. So no java and servlet stuffs are allowed...
The reason is, calling a java/servlet class will take time which must be avoided.
I mean, the time between the jsp->java->jsp cycle can be avoided if we use Ajax. This could be effective i believe (i mean, doing on the client side).
fREDDIE
acoder 16,027
Recognized Expert Moderator MVP
I'm not saying not to use Ajax. What I suggested was that you call the JSP page via Ajax/XmlHttp.
I'm not saying not to use Ajax. What I suggested was that you call the JSP page via Ajax/XmlHttp.
Yeah. That is also one way of doing it. But at the end of the day when a jsp page gets compiled it is going to be a java/servlet class only right, which is want I wanted to avoid.
All I’m trying is to do is to finish of the whole stuff in a single jsp/html page. The control must not go to else where.
acoder 16,027
Recognized Expert Moderator MVP
In that case, create a new Date object - this will default to the current date/time to the millisecond. When finished, create another one and compare the two.
Yeah the same is what I have planned to do. Something like - result= response time-request time.
Okay, I ll brief it out again.
I request to open a site (using, “xmlHttp.open(" GET",url,true); ”) and I find the request time mean while. (The challenge here in this step is, I’m unable to call url’s like http://freddiemaize.wordpress.com which is a external domain. JavaScript doesn’t support cross domain scripting right?).
acoder 16,027
Recognized Expert Moderator MVP
For that you will have to use a proxy which is basically some server-side code which makes the request and passes back the response to the client. In effect, we're back to my earlier suggestion. It is possible to make cross-domain requests if you give privileges in a specific browser, but that would only work in one browser.
Hi fREDDIE,
you mentioned that u calculated server's response time in java... cud u tell me how to do so? i'm relatively new to java n need this urgently for my college project submission...
acoder 16,027
Recognized Expert Moderator MVP
Hi priyal, welcome to Bytes!
I would suggest you start a new thread for your question in the Java forum.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Ron Adam |
last post by:
Hi, I'm having fun learning Python and want to say thanks to everyone
here for a great programming language.
Below is my first Python program (not my first program) and I'd
apreciate any feedback on how I might do things differently to make it
either more consice, readable, or faster. ie... are there better ways
to do it in Python?
It won't break any records for calculating pi, that wasn't my goal,
learning Python was. But it might...
|
by: Rick Cook |
last post by:
I would like to do a response form on one of my sites instead of posting
an e-mail address for spammers. I've taken a couple of examples from
sites, but the code looks clunky and non-conformant to my inexperienced eye.
Also, on the sites I've found you can get the e-mail address simply by
viewing the page source. It seems to me there should be a way to hide
that, but as I say I'm hardly an expert.
Can anyone recommend a good site to...
|
by: Miller |
last post by:
Hi,
Can someone tell me how to calculate MFLOPS for the following C# code
(on a Pentium 4 2.0 Ghz)?
for (i=0; i<n; i++)
{
for (j=0; j<n; j++)
{
for (k=0; k<n; k++)
|
by: Vito DeCarlo |
last post by:
Over the past week, I've been noticing that any websites (on this one
particular web server) built with ASP.NET have unusually slow (5 second)
response times when moving through the site. There are times when the
delays dissappear, but they are existent 80% of the time.
This has only started up over the past week or so and I have checked CPU
usage, memory usage, etc. I've also reinstalled the 1.1 version of the .NET
framework just to...
|
by: Jean Johnson |
last post by:
Hello -
I have a start and end time that is written using the
following:
time.strftime("%b %d %Y %H:%M:%S")
How do I calculate the elapsed time?
JJ
| |
by: deisner |
last post by:
All-
I have a Framework 2.0 application running under Windows 2003 Server
and IIS utilizing the default application pool.
On my development machine (XP w/ IIS 5.1) the code runs perfectly. But
when deployed recompiled under 2003/6.0, every time the application
gets to a Response.Redirect (happens right away when a user logs in),
the Session data is lost.
|
by: badger_nz |
last post by:
Hi all,
I recently opened an account with a USA-based hosting company.
I'm new to the world of hosting providers, and I have a question
regarding performance that I'm hoping somebody here can answer in plain
language.
I have uploaded a static .html page onto my domain. The page links in
two stylesheets and a few images - total page size is 65kb. I opened an
|
by: mosesdinakaran |
last post by:
Hi All,
I need a small clarification in submitting the forms, Ur
suggestions please.
In a page I have two form and also two submit butons.
(ie)
|
by: mfaisalwarraich |
last post by:
Hi everybody. I have some problem while calculating time. i have employees who are working on hourly basis. i want to calculate the time. for example if an employee start working at 11:00pm (10-November-2008) and finish his job at 8:00am (11-November-2008) then how i can calculate the time between two different dates? i used dateDiffer method but it only displays the time difference between one date. please tell me how i can do this. thank you....
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |