I am writing an applet to display Julian Day and Time on a webpage. I have
all the code written except for a class to open a socket and extract a
String with the time in it. I am getting the time from (NIST), a government
site.
The problem that I am running into is that it seems that I can extract the
time from the server as application, but when changing the code so that will
run as an applet it hangs up. Here is a sample of the application code:
import java.io.* ;
import java.net.* ;
public class SocketTest{
public static void main(String[] args){
try{
Socket s = new Socket("time-A.timefreq.bldrdoc.gov", 13);
BufferedReader in = new BufferedReader
(new InputStreamReader(s.getInputStream()));
boolean more = true;
while(more){
String line = in.readLine();
if(line == null)
more = false;
else
System.out.println(line);
}}
catch(IOExeption e) {}
}}
This works just fine, but when I try to change the app into an applet, it
does not work. Can someone offer their skills.
Thanks
John 10 8118
Security problem.
"RadioFreq" <ra*******@earthlink.net> wrote in message
news:PE******************@newsread2.news.pas.earth link.net... I am writing an applet to display Julian Day and Time on a webpage. I have all the code written except for a class to open a socket and extract a String with the time in it. I am getting the time from (NIST), a
government site.
The problem that I am running into is that it seems that I can extract the time from the server as application, but when changing the code so that
will run as an applet it hangs up. Here is a sample of the application code:
import java.io.* ; import java.net.* ;
public class SocketTest{ public static void main(String[] args){ try{ Socket s = new Socket("time-A.timefreq.bldrdoc.gov", 13); BufferedReader in = new BufferedReader (new InputStreamReader(s.getInputStream())); boolean more = true; while(more){ String line = in.readLine(); if(line == null) more = false; else System.out.println(line); }} catch(IOExeption e) {} }}
This works just fine, but when I try to change the app into an applet, it does not work. Can someone offer their skills.
Thanks John
Thanks Thomas,
Security on my side or far side?
I do have a wireless network with a firewall, but I don't have any problems
with the application. Hmmm?
"Thomas A. Li" <tl*@corporola.com> wrote in message
news:ef*******************@news04.bloor.is.net.cab le.rogers.com... Security problem.
"RadioFreq" <ra*******@earthlink.net> wrote in message news:PE******************@newsread2.news.pas.earth link.net... I am writing an applet to display Julian Day and Time on a webpage. I
have all the code written except for a class to open a socket and extract a String with the time in it. I am getting the time from (NIST), a government site.
The problem that I am running into is that it seems that I can extract
the time from the server as application, but when changing the code so that will run as an applet it hangs up. Here is a sample of the application code:
import java.io.* ; import java.net.* ;
public class SocketTest{ public static void main(String[] args){ try{ Socket s = new Socket("time-A.timefreq.bldrdoc.gov", 13); BufferedReader in = new BufferedReader (new InputStreamReader(s.getInputStream())); boolean more = true; while(more){ String line = in.readLine(); if(line == null) more = false; else System.out.println(line); }} catch(IOExeption e) {} }}
This works just fine, but when I try to change the app into an applet,
it does not work. Can someone offer their skills.
Thanks John
Check out java.sun.com for details on Java issues first: http://java.sun.com/developer/techni...urity/applets/
"RadioFreq" <ra*******@earthlink.net> wrote in message
news:cR******************@newsread2.news.pas.earth link.net... Thanks Thomas,
Security on my side or far side? I do have a wireless network with a firewall, but I don't have any
problems with the application. Hmmm?
"Thomas A. Li" <tl*@corporola.com> wrote in message news:ef*******************@news04.bloor.is.net.cab le.rogers.com... Security problem.
"RadioFreq" <ra*******@earthlink.net> wrote in message news:PE******************@newsread2.news.pas.earth link.net... I am writing an applet to display Julian Day and Time on a webpage. I have all the code written except for a class to open a socket and extract a String with the time in it. I am getting the time from (NIST), a government site.
The problem that I am running into is that it seems that I can extract the time from the server as application, but when changing the code so
that will run as an applet it hangs up. Here is a sample of the application
code: import java.io.* ; import java.net.* ;
public class SocketTest{ public static void main(String[] args){ try{ Socket s = new Socket("time-A.timefreq.bldrdoc.gov", 13); BufferedReader in = new BufferedReader (new InputStreamReader(s.getInputStream())); boolean more = true; while(more){ String line = in.readLine(); if(line == null) more = false; else System.out.println(line); }} catch(IOExeption e) {} }}
This works just fine, but when I try to change the app into an applet,
it does not work. Can someone offer their skills.
Thanks John
you probably don't need to know the time from NIST
because there is a good chance that your server is
synchronized with it via ntp so just use "date"
Besides if your server is synchronized, "date" will
probably give you a more accurate result than you
can do for yourself. Ntp sync takes care of packet
delay times.
"Thomas A. Li" <tl*@corporola.com> wrote in message
news:Sj*****************@twister01.bloor.is.net.ca ble.rogers.com... Check out java.sun.com for details on Java issues first:
http://java.sun.com/developer/techni...urity/applets/
"RadioFreq" <ra*******@earthlink.net> wrote in message news:cR******************@newsread2.news.pas.earth link.net... Thanks Thomas,
Security on my side or far side? I do have a wireless network with a firewall, but I don't have any problems with the application. Hmmm?
"Thomas A. Li" <tl*@corporola.com> wrote in message news:ef*******************@news04.bloor.is.net.cab le.rogers.com... Security problem.
"RadioFreq" <ra*******@earthlink.net> wrote in message news:PE******************@newsread2.news.pas.earth link.net... > I am writing an applet to display Julian Day and Time on a webpage.
I have > all the code written except for a class to open a socket and extract
a > String with the time in it. I am getting the time from (NIST), a government > site. > > The problem that I am running into is that it seems that I can
extract the > time from the server as application, but when changing the code so that will > run as an applet it hangs up. Here is a sample of the application code: > > import java.io.* ; > import java.net.* ; > > public class SocketTest{ > public static void main(String[] args){ > try{ > Socket s = new Socket("time-A.timefreq.bldrdoc.gov",
13); > BufferedReader in = new BufferedReader > (new InputStreamReader(s.getInputStream())); > boolean more = true; > while(more){ > String line = in.readLine(); > if(line == null) > more = false; > else > System.out.println(line); > }} > catch(IOExeption e) {} > }} > > This works just fine, but when I try to change the app into an
applet, it > does not work. Can someone offer their skills. > > Thanks > John > >
Thanks Thomas,
I now realize what is happening. An example of what I am doing is on my
webpage of astronomy-watch.com, where I can only extract the client machines
time. The problem with this is, to predict Satellite passes the user needs
to have the correct time +/- 2 seconds. Client machines can be off from
several minutes to hours if not properly maintained.
Obviously, this is done in a different way other than opening a socket. For
instance, looking at the time.gov/ site will display on the browser the real
time. Is this time seeded from the server side?
Thanks for your time, it's really appreciated!
John
"Thomas A. Li" <tl*@corporola.com> wrote in message
news:Sj*****************@twister01.bloor.is.net.ca ble.rogers.com... Check out java.sun.com for details on Java issues first:
http://java.sun.com/developer/techni...urity/applets/
Thanks 'NOS',
In my current applet I use the 'GregorianCalendar' method to extract the
date/time information. If I use the 'Date' method am I extracting the server
machine's time or the client machine's time? I do know that
GregorianCalendar is using the client machine's time.
Thanks
John
"nos" <no*@nospam.com> wrote in message
news:LjoCb.374875$275.1216915@attbi_s53... you probably don't need to know the time from NIST because there is a good chance that your server is synchronized with it via ntp so just use "date" Besides if your server is synchronized, "date" will probably give you a more accurate result than you can do for yourself. Ntp sync takes care of packet delay times.
Ok so now I have to put on my thinking hat.
Date and calendar both get time from the client machine
which may or may not be synchronized to anything.
Windows XP synchronizes itself to nist, but only once
per week. Solaris comes
with ntp and it is most likely synchronized via the network.
But since you have no control over the client machine you have
to assume it is not synchronized.
Sorry to have mislead you but I am sort of stumped right now, maybe later
something will occur to me.
"RadioFreq" <ra*******@earthlink.net> wrote in message
news:i5***************@newsread1.news.pas.earthlin k.net... Thanks Thomas,
I now realize what is happening. An example of what I am doing is on my webpage of astronomy-watch.com, where I can only extract the client
machines time. The problem with this is, to predict Satellite passes the user needs to have the correct time +/- 2 seconds. Client machines can be off from several minutes to hours if not properly maintained.
Obviously, this is done in a different way other than opening a socket.
For instance, looking at the time.gov/ site will display on the browser the
real time. Is this time seeded from the server side?
Thanks for your time, it's really appreciated! John
"Thomas A. Li" <tl*@corporola.com> wrote in message news:Sj*****************@twister01.bloor.is.net.ca ble.rogers.com... Check out java.sun.com for details on Java issues first:
http://java.sun.com/developer/techni...urity/applets/
RadioFreq wrote: I am writing an applet to display Julian Day and Time on a webpage. I have all the code written except for a class to open a socket and extract a String with the time in it. I am getting the time from (NIST), a government site.
The problem that I am running into is that it seems that I can extract the time from the server as application, but when changing the code so that will run as an applet it hangs up.
As you have discovered in other threads, the issue is that the applet
sandbox will not let you talk to servers other that the one that the
applet is served from.
There are two common work-arounds:
1) Create a signed applet that requests permission to contact other
servers from the client.
2) Create some sort of server to run on the machine serving the applet
and have the applet get the time from that server. (There are many
options here: RMI, EJB, simple relay server, servlet, etc. Perhaps the
date service is already running on the server?)
Personally, assuming it is appropriate for your application, I would
consider re-writing the applet as a servlet or a JSP page.
Ray
Thanks Ray,
I am considering using a JSP as way to extract the time from the server and
produce the HTML with the time seeded from the server.
Thanks
"Raymond DeCampo" <rd******@spam-I-am-not.twcny.rr.com> wrote in message
news:u8*****************@twister.nyroc.rr.com... RadioFreq wrote: I am writing an applet to display Julian Day and Time on a webpage. I
have all the code written except for a class to open a socket and extract a String with the time in it. I am getting the time from (NIST), a
government site.
The problem that I am running into is that it seems that I can extract
the time from the server as application, but when changing the code so that
will run as an applet it hangs up.
As you have discovered in other threads, the issue is that the applet sandbox will not let you talk to servers other that the one that the applet is served from.
There are two common work-arounds:
1) Create a signed applet that requests permission to contact other servers from the client. 2) Create some sort of server to run on the machine serving the applet and have the applet get the time from that server. (There are many options here: RMI, EJB, simple relay server, servlet, etc. Perhaps the date service is already running on the server?)
Personally, assuming it is appropriate for your application, I would consider re-writing the applet as a servlet or a JSP page.
Ray
I think I have a solution.
I will use a JSP servlet to retrieve the server time, then seed this server
time to the applet.
I don't know why I didn't think about this before. Sometimes I just have to
sit back and look at my problem from different angle.
At least, you answered my question as to why I couldn't open a socket with
an applet. I'll let everyone know how this turns out.
Thanks for all you help.
Free the Code - OpenSource!
John
"nos" <no*@nospam.com> wrote in message
news:dhsCb.377197$ao4.1258920@attbi_s51... Ok so now I have to put on my thinking hat. Date and calendar both get time from the client machine which may or may not be synchronized to anything. Windows XP synchronizes itself to nist, but only once per week. Solaris comes with ntp and it is most likely synchronized via the network. But since you have no control over the client machine you have to assume it is not synchronized. Sorry to have mislead you but I am sort of stumped right now, maybe later something will occur to me.
"RadioFreq" <ra*******@earthlink.net> wrote in message news:i5***************@newsread1.news.pas.earthlin k.net... Thanks Thomas,
I now realize what is happening. An example of what I am doing is on my webpage of astronomy-watch.com, where I can only extract the client machines time. The problem with this is, to predict Satellite passes the user
needs to have the correct time +/- 2 seconds. Client machines can be off from several minutes to hours if not properly maintained.
Obviously, this is done in a different way other than opening a socket. For instance, looking at the time.gov/ site will display on the browser the real time. Is this time seeded from the server side?
Thanks for your time, it's really appreciated! John
"Thomas A. Li" <tl*@corporola.com> wrote in message news:Sj*****************@twister01.bloor.is.net.ca ble.rogers.com... Check out java.sun.com for details on Java issues first:
http://java.sun.com/developer/techni...urity/applets/
This discussion thread is closed Replies have been disabled for this discussion. Similar topics
1 post
views
Thread by Guy Erez |
last post: by
|
2 posts
views
Thread by Reddy |
last post: by
|
4 posts
views
Thread by James Pemberton |
last post: by
|
8 posts
views
Thread by Jeff |
last post: by
|
2 posts
views
Thread by dave m |
last post: by
| | |
1 post
views
Thread by i.sobha |
last post: by
|
6 posts
views
Thread by Igor |
last post: by
| | | | | | | | | | |