Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing work station time to servlet?

Status
Not open for further replies.

TomBarns

Programmer
Feb 14, 2001
10
US
I'm trying to get the work station time using javascript.
then i want to pass it(time) with the url to a servlet,because i need to count the time of loading and servicing time for the servlet.
Here is a sample code and i know that doesn't work,i need to know how to access that script,or in other i need to call that script and assign the value from it to a variable,then i append that variable to the url.
i could do it without frameset,but i need to make it work with frameset to be able to send concurrent requests.
thanks for your help.
//code===============
<html>
<form>
<script language = &quot;javascript1.2&quot;>
function getTime()
{
return new Date().getTime();
}
</script>

<frameset rows=&quot;*,*&quot;>
<frame src=&quot; >
</frameset>
</form>
</html>
//=========================
 
I guess you are getting &quot;getTime()&quot; - when you ask the response object for that parameter aren't you?

This is because the query string is interpreted as just that a string - statements will not execute. Just write a function which get's the time, and then appends it to the string - then send it to the servlet. (Javascript will convert the integers to strings automatically)

function getTimeAndSend(){
var time = getTime();
var newSRC = &quot; + time;
parent.frameName.src = newSRC;


}

b2 - benbiddington@surf4nix.com
 
Hi,

Another way which you might want to use is you can create a method in javascript, which a link or button will call when clicked. This method would first get the time of the client machine and then submit this time as a parameter into the servlet.

So in the servlet, you would use the getParameter() method to retrieve client machine's time :)

Regards,
Leon If you need additional help, you can email to me at zaoliang@hotmail.com I don't guaranty that I will be able to solve your problems but I will try my best :)
 
Hey, is there an echo in here? :-Q
b2 - benbiddington@surf4nix.com
 
Well, sort of :D If you need additional help, you can email to me at zaoliang@hotmail.com I don't guaranty that I will be able to solve your problems but I will try my best :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top