Hello. I need to use java to check if a server is up and i am trying to do
it with sockets but i understand there are security issues. The aim is this.
There is a members only site that sometimes goes down for mainetenence
This applet needs to contact this site to get a response, any response and
if it does then the site is up. if not then the site is down. Anyone know
how I can acheive this>
TIA
|
|
0
|
|
|
|
Reply
|
Darren
|
9/4/2005 4:17:49 PM |
|
"Darren" <Daz@devslashnul.net> wrote in message
news:N6FSe.1616$741.659@newsfe6-gui.ntli.net...
> Hello. I need to use java to check if a server is up and i am trying to do
> it with sockets but i understand there are security issues. The aim is
> this.
> There is a members only site that sometimes goes down for mainetenence
> This applet needs to contact this site to get a response, any response and
> if it does then the site is up. if not then the site is down. Anyone know
> how I can acheive this>
The security issue you're talking about is that fact that an unprivileged
applet can open a connection only to the server from which it came. The
easy "fix" for you in this case is to put the access test into a servlet or
script on the server that hosts the applet--the servlet will not have any
restrictions for reaching the 3rd party machine. The applet can then talk
to your servlet, script, whatever. Alternatively, you can sign the applet
and allow it to request privilege from the user or persuade the user to add
the privilege to the JVM security file--IMHO these are much more difficult.
Further information about applet is here
http://mindprod.com/jgloss/applet.html
Aside from that, just open a connection to the web site and make a request.
You can use HTTPConnection or a direct socket connection, depending on
whichever you find easiest.
The fundamental problem with polling to see if a server is "up", however, is
that the information is really only good at the time of the poll. The
server could go down immediately after the poll. You're probably fine,
though, if you're only interested in whether the server was recently up or
down.
Cheers,
|
|
0
|
|
|
|
Reply
|
matth4371 (344)
|
9/4/2005 5:03:50 PM
|
|
> Hello. I need to use java to check if a server is up and i am trying to do
> it with sockets but i understand there are security issues.
There may also be legal issues. If the server isn't yours, maybe you have no
business testing its status since that may fall well foul of the site's
terms of use. Especially if you start "testing" it at regular intervals....
Depending on the physical location of the server and its legal jurisdiction,
you may also be committing a crime by accessing the machine. You may have
noticed that law enforcement agencies are having a lot more success these
days tracking down people who don't want to respect statutes like the
Computer Misuse Act (applies to the UK).
|
|
0
|
|
|
|
Reply
|
jan
|
9/4/2005 6:31:07 PM
|
|
On Sun, 04 Sep 2005 16:17:49 GMT, "Darren" <Daz@devslashnul.net> wrote
or quoted :
>Hello. I need to use java to check if a server is up and i am trying to do
>it with sockets but i understand there are security issues. The aim is this.
>There is a members only site that sometimes goes down for mainetenence
>This applet needs to contact this site to get a response, any response and
>if it does then the site is up. if not then the site is down. Anyone know
>how I can acheive this>
generally you can get a response from the base site url e.g.
http://mindprod.com
You simulate what a browser does with a GET. See
http://mindprod.com/applets/fileio.html
for how
It will show you the raw sockets way and the HTTPURLConnection way
If that is not sufficient, email me with the word "voter" in the
subject and I will send you some sample code.
To learn more, you want Marty Hall's book, see
http://mindprod.com/jgloss/cgi.html for a link
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
|
|
0
|
|
|
|
Reply
|
Roedy
|
9/4/2005 9:46:51 PM
|
|
On Sun, 4 Sep 2005 13:03:50 -0400, "Matt Humphrey"
<matth@ivizNOSPAM.com> wrote or quoted :
>The security issue you're talking about is that fact that an unprivileged
>applet can open a connection only to the server from which it came. The
>easy "fix" for you in this case is to put the access test into a servlet or
>script on the server that hosts the applet--the servlet will not have any
>restrictions for reaching the 3rd party machine. The applet can then talk
>to your servlet, script, whatever. Alternatively, you can sign the applet
>and allow it to request privilege from the user or persuade the user to add
>the privilege to the JVM security file--IMHO these are much more difficult.
>Further information about applet is here
>http://mindprod.com/jgloss/applet.html
Other ways out:
1. signing the applet
2. using JAWS
see http://mindprod.com/jgloss/jaws.html
http://mindprod.com/jgloss/signedapplets.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
|
|
0
|
|
|
|
Reply
|
look-on (3298)
|
9/4/2005 9:47:57 PM
|
|
On Sun, 04 Sep 2005 16:17:49 GMT, "Darren" <Daz@devslashnul.net> wrote
or quoted :
>I need to use java to check if a server is up and i am trying to do
>it with sockets but i understand there are security issues.
I assumed you meant HTTP server. If not, then you have to find a
protocol it does support when it is up, e.g. ping or NTP. You Then are
likely involved with Datagrams.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
|
|
0
|
|
|
|
Reply
|
Roedy
|
9/4/2005 9:49:37 PM
|
|
"jan V" <nul@nul.be> wrote in message
news:L3HSe.186018$JD7.10323046@phobos.telenet-ops.be...
> > Hello. I need to use java to check if a server is up and i am trying to
do
> > it with sockets but i understand there are security issues.
>
> There may also be legal issues. If the server isn't yours, maybe you have
no
> business testing its status since that may fall well foul of the site's
> terms of use. Especially if you start "testing" it at regular
intervals....
>
> Depending on the physical location of the server and its legal
jurisdiction,
> you may also be committing a crime by accessing the machine. You may have
> noticed that law enforcement agencies are having a lot more success these
> days tracking down people who don't want to respect statutes like the
> Computer Misuse Act (applies to the UK).
To put your mind at rest the server and all its contents are my personal
property. So what now?
>
>
|
|
0
|
|
|
|
Reply
|
Darren
|
9/5/2005 10:53:04 AM
|
|
> To put your mind at rest the server and all its contents are my personal
> property. So what now?
Then you've got a big green light. Matt's or Roedy's suggestions should give
you possible approaches to try out.
[BTW, I hope you don;t think I was being funny talking about law. It's not
only high-profile companies like Napster and Kazzaa who end up in court for
falling foul of various legislation]
|
|
0
|
|
|
|
Reply
|
jan
|
9/5/2005 11:59:16 AM
|
|
"jan V" <nul@nul.be> wrote in message
news:oqWSe.186550$Uc.10334240@phobos.telenet-ops.be...
> > To put your mind at rest the server and all its contents are my personal
> > property. So what now?
>
> Then you've got a big green light. Matt's or Roedy's suggestions should
give
> you possible approaches to try out.
>
> [BTW, I hope you don;t think I was being funny talking about law. It's not
> only high-profile companies like Napster and Kazzaa who end up in court
for
> falling foul of various legislation]
>
No I don't think you were trying to be funny,. It's safe to assume some
hacking attempts are on the go in todays scheme of things . :)
>
|
|
0
|
|
|
|
Reply
|
Darren
|
9/5/2005 12:39:41 PM
|
|
"Matt Humphrey" <matth@ivizNOSPAM.com> wrote in message
news:ceOdnZ94NJqdtIbeRVn-3g@adelphia.com...
>
> "Darren" <Daz@devslashnul.net> wrote in message
> news:N6FSe.1616$741.659@newsfe6-gui.ntli.net...
> > Hello. I need to use java to check if a server is up and i am trying to
do
> > it with sockets but i understand there are security issues. The aim is
> > this.
> > There is a members only site that sometimes goes down for mainetenence
> > This applet needs to contact this site to get a response, any response
and
> > if it does then the site is up. if not then the site is down. Anyone
know
> > how I can acheive this>
>
> The security issue you're talking about is that fact that an unprivileged
> applet can open a connection only to the server from which it came. The
> easy "fix" for you in this case is to put the access test into a servlet
or
> script on the server that hosts the applet--the servlet will not have any
> restrictions for reaching the 3rd party machine. The applet can then talk
> to your servlet, script, whatever. Alternatively, you can sign the applet
> and allow it to request privilege from the user or persuade the user to
add
> the privilege to the JVM security file--IMHO these are much more
difficult.
> Further information about applet is here
> http://mindprod.com/jgloss/applet.html
>
> Aside from that, just open a connection to the web site and make a
request.
> You can use HTTPConnection or a direct socket connection, depending on
> whichever you find easiest.
>
> The fundamental problem with polling to see if a server is "up", however,
is
> that the information is really only good at the time of the poll. The
> server could go down immediately after the poll. You're probably fine,
> though, if you're only interested in whether the server was recently up or
> down.
>
> Cheers,
Well I'm quite happy to do the check on http via GET as the web server
itself needs to be up for the check to proceed.
Here's what i got so far. So where do i go from here?
import java.awt.*;
import java.applet.*;
import java.net.*;
import java.io.*;
import java.security.*;
public class Helloserver extends Applet
{
private String hostname = "http://10.0.0.254";
private String port="80";
private URL location;
private Object content;
private String getStr = "GET / HTTP/1.1";
public void init()
{
hello();
}
public void paint(Graphics g)
{
g.drawString(hostname, 50, 60 );
}
/**
* Method hello
*
*
* @return
*
*/
protected final boolean hello()
{
InputStream goGetIt;
String host=hostname+":"+port;
hostname = host;
try
{
location=new URL(hostname);
}
catch(MalformedURLException u)
{
hostname=u.getMessage();
}
catch(IOException u)
{
hostname=u.getMessage();
}
return true;
}
}
>
>
|
|
0
|
|
|
|
Reply
|
Daz (100)
|
9/5/2005 1:08:18 PM
|
|
"Roedy Green" <look-on@mindprod.com.invalid> wrote in message
news:mtqmh1hck7c266gi1kfv9gsv40nrgloft7@4ax.com...
> On Sun, 04 Sep 2005 16:17:49 GMT, "Darren" <Daz@devslashnul.net> wrote
> or quoted :
>
> >I need to use java to check if a server is up and i am trying to do
> >it with sockets but i understand there are security issues.
>
> I assumed you meant HTTP server. If not, then you have to find a
> protocol it does support when it is up, e.g. ping or NTP. You Then are
> likely involved with Datagrams.
>
Nothing so complicated though i'll be looking at that in the future. For now
sending and getting a response from my http server will do the trick but how
do I do it in Java?
> --
> Canadian Mind Products, Roedy Green.
> http://mindprod.com Again taking new Java programming contracts.
|
|
0
|
|
|
|
Reply
|
Darren
|
9/5/2005 1:51:00 PM
|
|
"Darren" <Daz@devslashnul.net> wrote in message
news:83YSe.3034$zw1.2119@newsfe2-gui.ntli.net...
>
> "Roedy Green" <look-on@mindprod.com.invalid> wrote in message
> news:mtqmh1hck7c266gi1kfv9gsv40nrgloft7@4ax.com...
>> On Sun, 04 Sep 2005 16:17:49 GMT, "Darren" <Daz@devslashnul.net> wrote
>> or quoted :
>>
>> >I need to use java to check if a server is up and i am trying to do
>> >it with sockets but i understand there are security issues.
>>
>> I assumed you meant HTTP server. If not, then you have to find a
>> protocol it does support when it is up, e.g. ping or NTP. You Then are
>> likely involved with Datagrams.
>>
> Nothing so complicated though i'll be looking at that in the future. For
> now
> sending and getting a response from my http server will do the trick but
> how
> do I do it in Java?
Maybe HTTPClient is useful?
http://www.innovation.ch/java/HTTPClient/
If the code can be very simple for this:
try
{
HTTPConnection con = new HTTPConnection("the-site-to-test.com");
HTTPResponse rsp = con.Get("/test.htm");
if (rsp.getStatusCode() >= 300)
{
/*
the http server is online, but someting went wrong:
if the status code is in the 3xx range, then the request was
redirected (maybe as it should be?)
if the status code is in the 4xx range, then there was a client error,
and 5xx means server error
*/
}
}
catch (IOException e)
{
/*
this happens when the server is down. but it can also happen for some
other reason, like: time out, dns problem, a faulty internet
connection on the client side...
e.getMessage() should give some information. I my tests, I recieved a
ConnectException
(with the message "Connection refused") when the server was down.
To be more certain that there is no problem with the internet
connection on the client side
you can also try to contact a site that you "know" is online.
*/
}
If your server is made out of several different tiers, like Apache for pure
http, and Tomcat as a application server, then you can use the responseCode
to check if Tomcat is up and running smoothly. A 5xx error here would
indicate that Apache is up and running, but there is an issue with Tomcat.
/Jimi
|
|
0
|
|
|
|
Reply
|
Jimi
|
9/5/2005 2:38:58 PM
|
|
"Jimi Hulleg�rd" <ask_for_real_email@nothotmail.com> wrote in message
news:6MYSe.30519$hV3.12812@nntpserver.swip.net...
> "Darren" <Daz@devslashnul.net> wrote in message
> news:83YSe.3034$zw1.2119@newsfe2-gui.ntli.net...
> >
> > "Roedy Green" <look-on@mindprod.com.invalid> wrote in message
> > news:mtqmh1hck7c266gi1kfv9gsv40nrgloft7@4ax.com...
> >> On Sun, 04 Sep 2005 16:17:49 GMT, "Darren" <Daz@devslashnul.net> wrote
> >> or quoted :
> >>
> >> >I need to use java to check if a server is up and i am trying to do
> >> >it with sockets but i understand there are security issues.
> >>
> >> I assumed you meant HTTP server. If not, then you have to find a
> >> protocol it does support when it is up, e.g. ping or NTP. You Then are
> >> likely involved with Datagrams.
> >>
> > Nothing so complicated though i'll be looking at that in the future. For
> > now
> > sending and getting a response from my http server will do the trick but
> > how
> > do I do it in Java?
>
> Maybe HTTPClient is useful?
> http://www.innovation.ch/java/HTTPClient/
>
> If the code can be very simple for this:
>
> try
> {
> HTTPConnection con = new HTTPConnection("the-site-to-test.com");
> HTTPResponse rsp = con.Get("/test.htm");
> if (rsp.getStatusCode() >= 300)
> {
> /*
> the http server is online, but someting went wrong:
> if the status code is in the 3xx range, then the request was
> redirected (maybe as it should be?)
> if the status code is in the 4xx range, then there was a client
error,
> and 5xx means server error
> */
> }
> }
> catch (IOException e)
> {
> /*
> this happens when the server is down. but it can also happen for
some
> other reason, like: time out, dns problem, a faulty internet
> connection on the client side...
> e.getMessage() should give some information. I my tests, I recieved
a
> ConnectException
> (with the message "Connection refused") when the server was down.
>
> To be more certain that there is no problem with the internet
> connection on the client side
> you can also try to contact a site that you "know" is online.
> */
> }
>
> If your server is made out of several different tiers, like Apache for
pure
> http, and Tomcat as a application server, then you can use the
responseCode
> to check if Tomcat is up and running smoothly. A 5xx error here would
> indicate that Apache is up and running, but there is an issue with Tomcat.
What library is "HTTPConnection" in? My hava compiler doesn't recognise it.
>
> /Jimi
>
>
|
|
0
|
|
|
|
Reply
|
Darren
|
9/5/2005 2:57:35 PM
|
|
> public class Helloserver extends Applet
> {
> private String hostname = "http://10.0.0.254";
This is a very poorly chosen identifier. The String contains a URL, not a
host name. Even without the http:// your String would contain a host IP
address, not a host name.
> private String port="80";
portNumber would be a better choice. Declaring this as a constant would be
even better, since HTTP normally talks on port 80 and nothing else (in
*normal* circumstances)
> private URL location;
serverURL would be better.
> private Object content;
pageContent would be better. content on its own is much too vague.
> private String getStr = "GET / HTTP/1.1";
httpGETcommand maybe?
> g.drawString(hostname, 50, 60 );
Magic constants... not good.
> protected final boolean hello()
protected and final together? Doesn't make any sense whatsoever. Look up the
definition of the keywords.. you'll see why.
> InputStream goGetIt;
I give up... your identifiers range from poor to attrocious. Maybe that
doesn't bother you now, but it will sooner or later.
|
|
0
|
|
|
|
Reply
|
nul32 (392)
|
9/5/2005 2:58:57 PM
|
|
"Darren" <Daz@devslashnul.net> wrote in message
news:z1ZSe.2524$741.347@newsfe6-gui.ntli.net...
>
> "Jimi Hulleg�rd" <ask_for_real_email@nothotmail.com> wrote in message
> news:6MYSe.30519$hV3.12812@nntpserver.swip.net...
>> "Darren" <Daz@devslashnul.net> wrote in message
>> > For now sending and getting a response from my http server
>> > will do the trick but how do I do it in Java?
>>
>> Maybe HTTPClient is useful?
>> http://www.innovation.ch/java/HTTPClient/
>> [...]
>
> What library is "HTTPConnection" in? My hava compiler doesn't recognise
> it.
Did you visit the link? --> http://www.innovation.ch/java/HTTPClient/
There is a download link on that page.
/Jimi
|
|
0
|
|
|
|
Reply
|
Jimi
|
9/5/2005 3:45:29 PM
|
|
On Mon, 05 Sep 2005 14:58:57 GMT, jan V wrote:
...
>> InputStream goGetIt;
>
> I give up...
iDontGetIt..
|
|
0
|
|
|
|
Reply
|
SeeMySites (3836)
|
9/5/2005 4:10:29 PM
|
|
"jan V" <nul@nul.be> wrote in message
news:R2ZSe.186635$SC2.10246263@phobos.telenet-ops.be...
> > public class Helloserver extends Applet
> > {
> > private String hostname = "http://10.0.0.254";
>
> This is a very poorly chosen identifier. The String contains a URL, not a
> host name. Even without the http:// your String would contain a host IP
> address, not a host name.
>
> > private String port="80";
>
> portNumber would be a better choice. Declaring this as a constant would be
> even better, since HTTP normally talks on port 80 and nothing else (in
> *normal* circumstances)
>
> > private URL location;
>
> serverURL would be better.
>
> > private Object content;
>
> pageContent would be better. content on its own is much too vague.
>
> > private String getStr = "GET / HTTP/1.1";
>
> httpGETcommand maybe?
>
> > g.drawString(hostname, 50, 60 );
>
> Magic constants... not good.
>
> > protected final boolean hello()
>
> protected and final together? Doesn't make any sense whatsoever. Look up
the
> definition of the keywords.. you'll see why.
>
> > InputStream goGetIt;
>
> I give up... your identifiers range from poor to attrocious. Maybe that
> doesn't bother you now, but it will sooner or later.
You don't like my identifiers? God forbid you see my C code then. :)
Seriously my identifiers are chosen because they are suitable and readable
to me and after all this is not what I was asking though your point about
protected with final is accepted.
>
>
|
|
0
|
|
|
|
Reply
|
Daz (100)
|
9/5/2005 4:20:50 PM
|
|
"Andrew Thompson" <SeeMySites@www.invalid> wrote in message
news:hy57906d7p81.1qtbjsuuk3ro9$.dlg@40tude.net...
> On Mon, 05 Sep 2005 14:58:57 GMT, jan V wrote:
> ..
> >> InputStream goGetIt;
> >
> > I give up...
>
> iDontGetIt..
LOL
|
|
0
|
|
|
|
Reply
|
Daz (100)
|
9/5/2005 5:15:19 PM
|
|
"Jimi Hulleg�rd" <ask_for_real_email@nothotmail.com> wrote in message
news:82_Se.30551$hV3.12762@nntpserver.swip.net...
> "Darren" <Daz@devslashnul.net> wrote in message
> news:z1ZSe.2524$741.347@newsfe6-gui.ntli.net...
> >
> > "Jimi Hulleg�rd" <ask_for_real_email@nothotmail.com> wrote in message
> > news:6MYSe.30519$hV3.12812@nntpserver.swip.net...
> >> "Darren" <Daz@devslashnul.net> wrote in message
> >> > For now sending and getting a response from my http server
> >> > will do the trick but how do I do it in Java?
> >>
> >> Maybe HTTPClient is useful?
> >> http://www.innovation.ch/java/HTTPClient/
> >> [...]
> >
> > What library is "HTTPConnection" in? My hava compiler doesn't recognise
> > it.
>
> Did you visit the link? --> http://www.innovation.ch/java/HTTPClient/
> There is a download link on that page.
I just did. where do you unpack the files too? I'm assuning theres a
location windows keeps its java classes
>
> /Jimi
>
>
>
|
|
0
|
|
|
|
Reply
|
Darren
|
9/5/2005 5:42:07 PM
|
|
"Darren" <Daz@devslashnul.net> wrote in message
news:Pr%Se.2381$Pn1.520@newsfe4-gui.ntli.net...
>
> "Jimi Hulleg�rd" <ask_for_real_email@nothotmail.com> wrote in message
> news:82_Se.30551$hV3.12762@nntpserver.swip.net...
>> "Darren" <Daz@devslashnul.net> wrote in message
>> news:z1ZSe.2524$741.347@newsfe6-gui.ntli.net...
>> >
>> > "Jimi Hulleg�rd" <ask_for_real_email@nothotmail.com> wrote in message
>> > news:6MYSe.30519$hV3.12812@nntpserver.swip.net...
>> >> "Darren" <Daz@devslashnul.net> wrote in message
>> >> > For now sending and getting a response from my http server
>> >> > will do the trick but how do I do it in Java?
>> >>
>> >> Maybe HTTPClient is useful?
>> >> http://www.innovation.ch/java/HTTPClient/
>> >> [...]
>> >
>> > What library is "HTTPConnection" in? My hava compiler doesn't recognise
>> > it.
>>
>> Did you visit the link? --> http://www.innovation.ch/java/HTTPClient/
>> There is a download link on that page.
>
> I just did. where do you unpack the files too? I'm assuning theres a
> location windows keeps its java classes
Why download something when you already have everything you need?
try {
// Create a URL for the desired page
URL url = new URL(http://hostname:80/index.html);
// Read all the text returned by the server
BufferedReader in = new BufferedReader(new
InputStreamReader(url.openStream()));
String str;
while ((str = in.readLine()) != null) {
// str is one line of text; readLine() strips the newline character(s)
}
in.close();
} catch (MalformedURLException e) {
...
} catch (IOException e) {
...
}
now, if str contains the content of "index.html", your server is up...
--
Dag.
|
|
0
|
|
|
|
Reply
|
Dag
|
9/5/2005 7:25:34 PM
|
|
On Mon, 05 Sep 2005 13:51:00 GMT, "Darren" <Daz@devslashnul.net> wrote
or quoted :
>Nothing so complicated though i'll be looking at that in the future. For now
>sending and getting a response from my http server will do the trick but how
>do I do it in Java?
I think I have answered this before, but in case my response got lost
in the shuffle:
see http://mindprod.com/applets/fileio.html
Marty Hall's book Core Web Programming is invaluable. It is the only
book I have found that explains all the things you have to know to be
an Applet masquerading as a browser.
see http://mindprod.com/jgloss/cgi.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
|
|
0
|
|
|
|
Reply
|
Roedy
|
9/5/2005 8:59:43 PM
|
|
"Dag Sunde" <me@dagsunde.com> wrote in message
news:OY0Te.5125$qE.1157750@juliett.dax.net...
> "Darren" <Daz@devslashnul.net> wrote in message
> news:Pr%Se.2381$Pn1.520@newsfe4-gui.ntli.net...
> >
> > "Jimi Hulleg�rd" <ask_for_real_email@nothotmail.com> wrote in message
> > news:82_Se.30551$hV3.12762@nntpserver.swip.net...
> >> "Darren" <Daz@devslashnul.net> wrote in message
> >> news:z1ZSe.2524$741.347@newsfe6-gui.ntli.net...
> >> >
> >> > "Jimi Hulleg�rd" <ask_for_real_email@nothotmail.com> wrote in message
> >> > news:6MYSe.30519$hV3.12812@nntpserver.swip.net...
> >> >> "Darren" <Daz@devslashnul.net> wrote in message
> >> >> > For now sending and getting a response from my http server
> >> >> > will do the trick but how do I do it in Java?
> >> >>
> >> >> Maybe HTTPClient is useful?
> >> >> http://www.innovation.ch/java/HTTPClient/
> >> >> [...]
> >> >
> >> > What library is "HTTPConnection" in? My hava compiler doesn't
recognise
> >> > it.
> >>
> >> Did you visit the link? --> http://www.innovation.ch/java/HTTPClient/
> >> There is a download link on that page.
> >
> > I just did. where do you unpack the files too? I'm assuning theres a
> > location windows keeps its java classes
>
> Why download something when you already have everything you need?
>
> try {
> // Create a URL for the desired page
> URL url = new URL(http://hostname:80/index.html);
>
> // Read all the text returned by the server
> BufferedReader in = new BufferedReader(new
> InputStreamReader(url.openStream()));
> String str;
> while ((str = in.readLine()) != null) {
> // str is one line of text; readLine() strips the newline character(s)
> }
> in.close();
> } catch (MalformedURLException e) {
> ...
> } catch (IOException e) {
> ...
> }
>
> now, if str contains the content of "index.html", your server is up...
Is very muc what I'm looking for but i get
"java.security.AccessControlException: access denied
(java.net.SocketPermission 10.0.0.254:80 connect,resolve)"
So then I added
location=new URL(protocol+hostname);
server=location.getHost();
System.out.println(server);
SocketPermission sp = new SocketPermission (server, "connect,resolve");
BufferedReader in = new BufferedReader(new
InputStreamReader(location.openStream()));
Same error. I must be using "SocketPermission" wrong.
>
> --
> Dag.
>
>
|
|
0
|
|
|
|
Reply
|
Darren
|
9/5/2005 9:39:20 PM
|
|
"Darren" <Daz@devslashnul.net> wrote in message
news:cW2Te.2779$741.656@newsfe6-gui.ntli.net...
>
> "Dag Sunde" <me@dagsunde.com> wrote in message
> news:OY0Te.5125$qE.1157750@juliett.dax.net...
<snipped />
>> try {
>> // Create a URL for the desired page
>> URL url = new URL(http://hostname:80/index.html);
>>
>> // Read all the text returned by the server
>> BufferedReader in = new BufferedReader(new
>> InputStreamReader(url.openStream()));
>> String str;
>> while ((str = in.readLine()) != null) {
>> // str is one line of text; readLine() strips the newline
>> character(s)
>> }
>> in.close();
>> } catch (MalformedURLException e) {
>> ...
>> } catch (IOException e) {
>> ...
>> }
>>
>> now, if str contains the content of "index.html", your server is up...
> Is very muc what I'm looking for but i get
> "java.security.AccessControlException: access denied
> (java.net.SocketPermission 10.0.0.254:80 connect,resolve)"
> So then I added
>
> location=new URL(protocol+hostname);
> server=location.getHost();
> System.out.println(server);
>
> SocketPermission sp = new SocketPermission (server, "connect,resolve");
> BufferedReader in = new BufferedReader(new
> InputStreamReader(location.openStream()));
>
> Same error. I must be using "SocketPermission" wrong.
Is this an Applet, and are you trying to access another site that
the one hosting your Applet?
If so, you need to sign your Applet. There is no way you can do
cross-domain communication in an applet without either signing it,
or manually editing each users java.policy file.
--
Dag.
|
|
0
|
|
|
|
Reply
|
Dag
|
9/5/2005 9:55:16 PM
|
|
> You don't like my identifiers? God forbid you see my C code then. :)
I'm an atheist anyway, so, eh...
> Seriously my identifiers are chosen because they are suitable and readable
to me
No they're not. In 2 years (or 6 months, if you've got a rotten memory like
mine), you'll also have difficulty reading your own code with such
identifiers. It's a skill that takes a long time to develop (picking really
good identifiers), so I'm not criticizing you even if you've already
programmed for 15 years... Even Sun's source codes are littered with truly
attrocious identifiers (luckily mostly confined to non-public fields and
local vars).
> and after all this is not what I was asking
I know ;-) ... it's so damned risky to post your code on these NG. It's like
hanging your washing out for the whole street to see.
> though your point about protected with final is accepted.
My pleasure.
|
|
0
|
|
|
|
Reply
|
nul32 (392)
|
9/5/2005 10:12:44 PM
|
|
"jan V" <nul@nul.be> wrote in message
news:wp3Te.187017$uf2.10345597@phobos.telenet-ops.be...
> > You don't like my identifiers? God forbid you see my C code then. :)
>
> I'm an atheist anyway, so, eh...
A pedantic too, I suspect. ;)
>
> > Seriously my identifiers are chosen because they are suitable and
readable
> to me
>
> No they're not.
Erm I think i'm more qualified to state what is meaningful to me than you
are.
>In 2 years (or 6 months, if you've got a rotten memory like
> mine), you'll also have difficulty reading your own code with such
> identifiers. It's a skill that takes a long time to develop (picking
really
> good identifiers), so I'm not criticizing you even if you've already
> programmed for 15 years...
22 actually :) and in 2 years I doubt i'll remember what to code even does
so I'll have to track it but the identifiers won't offput me. :)
>Even Sun's source codes are littered with truly
> attrocious identifiers (luckily mostly confined to non-public fields and
> local vars).
That doesn't suprise me. IME people use identifiers they can identify with.
these are often less meaningful or complete gibberish to other people.
>
> > and after all this is not what I was asking
>
> I know ;-) ... it's so damned risky to post your code on these NG. It's
like
> hanging your washing out for the whole street to see.
Particularly my washing :)
>
> > though your point about protected with final is accepted.
>
> My pleasure.
>
>
|
|
0
|
|
|
|
Reply
|
Daz (100)
|
9/5/2005 10:25:42 PM
|
|
"Dag Sunde" <me@dagsunde.com> wrote in message
news:893Te.5135$qE.1158696@juliett.dax.net...
> "Darren" <Daz@devslashnul.net> wrote in message
> news:cW2Te.2779$741.656@newsfe6-gui.ntli.net...
> >
> > "Dag Sunde" <me@dagsunde.com> wrote in message
> > news:OY0Te.5125$qE.1157750@juliett.dax.net...
> <snipped />
> >> try {
> >> // Create a URL for the desired page
> >> URL url = new URL(http://hostname:80/index.html);
> >>
> >> // Read all the text returned by the server
> >> BufferedReader in = new BufferedReader(new
> >> InputStreamReader(url.openStream()));
> >> String str;
> >> while ((str = in.readLine()) != null) {
> >> // str is one line of text; readLine() strips the newline
> >> character(s)
> >> }
> >> in.close();
> >> } catch (MalformedURLException e) {
> >> ...
> >> } catch (IOException e) {
> >> ...
> >> }
> >>
> >> now, if str contains the content of "index.html", your server is up...
> > Is very muc what I'm looking for but i get
> > "java.security.AccessControlException: access denied
> > (java.net.SocketPermission 10.0.0.254:80 connect,resolve)"
> > So then I added
> >
> > location=new URL(protocol+hostname);
> > server=location.getHost();
> > System.out.println(server);
> >
> > SocketPermission sp = new SocketPermission (server,
"connect,resolve");
> > BufferedReader in = new BufferedReader(new
> > InputStreamReader(location.openStream()));
> >
> > Same error. I must be using "SocketPermission" wrong.
>
> Is this an Applet, and are you trying to access another site that
> the one hosting your Applet?
>
> If so, you need to sign your Applet. There is no way you can do
> cross-domain communication in an applet without either signing it,
> or manually editing each users java.policy file.
Yes, wel the idea is this
A public site hosts my web page but on this site there is a link to a
members only site which resides on a box i am hosting. my public web page is
on a server that offers no server side scripting or i would knock together a
server side script to do the job so i'm stuck with client side Now i don't
think flash or javascript can do what i want so i'm stuck with using java
which isn't a bad thing because i happen to like the language.
Now where was I?
The public web page will have a link on it which will only show when my
members only server is up. the making the link work or not work is easy but
the checking of server status is a tougher option so i should do it with an
applet if possible. so what do i do with users java policies and or how do i
get this script signed?
Thanks in advance
>
> --
> Dag.
>
>
|
|
0
|
|
|
|
Reply
|
Darren
|
9/5/2005 10:35:21 PM
|
|
> >In 2 years (or 6 months, if you've got a rotten memory like
> > mine), you'll also have difficulty reading your own code with such
> > identifiers. It's a skill that takes a long time to develop (picking
> really
> > good identifiers), so I'm not criticizing you even if you've already
> > programmed for 15 years...
>
> 22 actually :) and in 2 years I doubt i'll remember what to code even does
> so I'll have to track it but the identifiers won't offput me. :)
I guess we're a bit different then. I just hate it when I read code I've
written 2, 5, 9 years ago (in case of Java) and I find the reading a bit
awkward simply because the identifiers could have been so much better. It's
really only in the last five or so years that I've really started becoming
(very) conscious about the need to craft identifiers that withstand the test
of time. Code that withstands the readability test after years and years,
that's what I call quality code (provided it works, and the architecture it
expresses is clean too of course).
> >Even Sun's source codes are littered with truly
> > attrocious identifiers (luckily mostly confined to non-public fields and
> > local vars).
>
> That doesn't suprise me. IME people use identifiers they can identify
with.
> these are often less meaningful or complete gibberish to other people.
As I've written in some other post/reply in this group, writing code should
be done with other programmers in mind. That requires clarity, minimum of
ambiguity etc,
|
|
0
|
|
|
|
Reply
|
nul32 (392)
|
9/5/2005 10:50:41 PM
|
|
On Mon, 5 Sep 2005 16:38:58 +0200, "Jimi Hulleg�rd"
<ask_for_real_email@nothotmail.com> wrote or quoted :
>Maybe HTTPClient is useful?
>http://www.innovation.ch/java/HTTPClient/
there a few more libraries: see
http://mindprod.com/jgloss/httpclient.html
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
|
|
0
|
|
|
|
Reply
|
Roedy
|
9/5/2005 11:14:46 PM
|
|
"jan V" <nul@nul.be> wrote in message
news:5Z3Te.187040$_Y5.10364986@phobos.telenet-ops.be...
> > >In 2 years (or 6 months, if you've got a rotten memory like
> > > mine), you'll also have difficulty reading your own code with such
> > > identifiers. It's a skill that takes a long time to develop (picking
> > really
> > > good identifiers), so I'm not criticizing you even if you've already
> > > programmed for 15 years...
> >
> > 22 actually :) and in 2 years I doubt i'll remember what to code even
does
> > so I'll have to track it but the identifiers won't offput me. :)
>
> I guess we're a bit different then. I just hate it when I read code I've
> written 2, 5, 9 years ago (in case of Java) and I find the reading a bit
> awkward simply because the identifiers could have been so much better.
It's
> really only in the last five or so years that I've really started becoming
> (very) conscious about the need to craft identifiers that withstand the
test
> of time. Code that withstands the readability test after years and years,
> that's what I call quality code (provided it works, and the architecture
it
> expresses is clean too of course).
>
> > >Even Sun's source codes are littered with truly
> > > attrocious identifiers (luckily mostly confined to non-public fields
and
> > > local vars).
> >
> > That doesn't suprise me. IME people use identifiers they can identify
> with.
> > these are often less meaningful or complete gibberish to other people.
>
> As I've written in some other post/reply in this group, writing code
should
> be done with other programmers in mind. That requires clarity, minimum of
> ambiguity etc,
what should be and what is are often very different. I still remember the
software lifecylce yet a large quantity of software houses and thier
programmers don't use it.
>
>
|
|
0
|
|
|
|
Reply
|
Daz (100)
|
9/5/2005 11:46:18 PM
|
|
"Darren" <Daz@devslashnul.net> wrote in message
news:JK3Te.3104$zw1.798@newsfe2-gui.ntli.net...
>
> "Dag Sunde" <me@dagsunde.com> wrote in message
> news:893Te.5135$qE.1158696@juliett.dax.net...
<snipped />
>> Is this an Applet, and are you trying to access another site that
>> the one hosting your Applet?
>>
>> If so, you need to sign your Applet. There is no way you can do
>> cross-domain communication in an applet without either signing it,
>> or manually editing each users java.policy file.
>
> Yes, wel the idea is this
> A public site hosts my web page but on this site there is a link to a
> members only site which resides on a box i am hosting. my public web page
> is
> on a server that offers no server side scripting or i would knock together
> a
> server side script to do the job so i'm stuck with client side Now i
> don't
> think flash or javascript can do what i want so i'm stuck with using java
> which isn't a bad thing because i happen to like the language.
> Now where was I?
> The public web page will have a link on it which will only show when my
> members only server is up. the making the link work or not work is easy
> but
> the checking of server status is a tougher option so i should do it with
> an
> applet if possible. so what do i do with users java policies and or how do
> i
> get this script signed?
Google for it!
You can also search this NG for several threads on the subject.
Here is a couple to get you started.
<http://groups.google.no/group/comp.lang.java.programmer/browse_thread/thread/7030468c124d26ac/165ce09248660543>
http://groups.google.no/group/comp.lang.java.programmer/browse_frm/thread/b05fbae81cba09d9/f3655aec2a6c7387#f3655aec2a6c7387
A fair warning, thou... This is *not* the easiest part of Java to dive into.
The documentation on this subject is very abstract and vague. (IMO).
--
Dag.
|
|
0
|
|
|
|
Reply
|
Dag
|
9/6/2005 7:25:30 AM
|
|
> what should be and what is are often very different.
True. What 'is ' is often the result of laziness and/or a general "don't
care" attitude. Look at how our world is... and how much "don't care"
pervades our society...
> I still remember the software lifecylce yet a large quantity of software
houses and thier programmers don't use it.
There is no *the* software lifecycle, there are many, all reflecting the
methodology you pick or believe in. But your point is taken: the vast
majority of software houses pay lipservice to the word methodology.
To prove that this situation is nothing less than scandalous, think of the
building trade. That industry is subject to lots and *lots* of statutory
building controls, with legal penalties associated with breaking those
building codes, including criminal prosecution in case people get hurt as a
result. How would average Joe regard a building firm which treats building
codes as an obstacle to making profit? Average Joe would be shocked and
demand such company be barred from trading, or clean up its act. Now compare
to our industry. :-((
|
|
0
|
|
|
|
Reply
|
nul32 (392)
|
9/6/2005 7:25:51 AM
|
|
"jan V" <nul@nul.be> wrote in message
news:3wbTe.187189$TA2.10354712@phobos.telenet-ops.be...
> > what should be and what is are often very different.
>
> True. What 'is ' is often the result of laziness and/or a general "don't
> care" attitude. Look at how our world is... and how much "don't care"
> pervades our society...
>
> > I still remember the software lifecylce yet a large quantity of software
> houses and thier programmers don't use it.
>
> There is no *the* software lifecycle, there are many, all reflecting the
> methodology you pick or believe in.
I spent three years in university learning *The* software lifecycle and not
*A* software lifecycle but that was many moons ago. A lot could have
ha[[ened since then.
>But your point is taken: the vast
> majority of software houses pay lipservice to the word methodology.
They put it down to software constraints but the truth is if they used *the*
software lifecycle then they may well save time but then again,what do I
know?
>
> To prove that this situation is nothing less than scandalous, think of the
> building trade. That industry is subject to lots and *lots* of statutory
> building controls, with legal penalties associated with breaking those
> building codes, including criminal prosecution in case people get hurt as
a
> result. How would average Joe regard a building firm which treats building
> codes as an obstacle to making profit? Average Joe would be shocked and
> demand such company be barred from trading, or clean up its act. Now
compare
> to our industry. :-((
Software companies will justify that software will not fall apart like badly
designed buildings but if that software is controlling aricraft or life
support machines the EEEEEEEEK
>
>
|
|
0
|
|
|
|
Reply
|
Daz (100)
|
9/6/2005 9:40:38 AM
|
|
"Roedy Green" <look-on@mindprod.com.invalid> wrote in message
news:pacph1di1rp3v6bgfpasdaaibagvhmdrk5@4ax.com...
> On Mon, 05 Sep 2005 13:51:00 GMT, "Darren" <Daz@devslashnul.net> wrote
> or quoted :
>
> >Nothing so complicated though i'll be looking at that in the future. For
now
> >sending and getting a response from my http server will do the trick but
how
> >do I do it in Java?
>
> I think I have answered this before, but in case my response got lost
> in the shuffle:
>
> see http://mindprod.com/applets/fileio.html
You did now i'm falling foul of signed script security issues
>
> Marty Hall's book Core Web Programming is invaluable. It is the only
> book I have found that explains all the things you have to know to be
> an Applet masquerading as a browser.
>
> see http://mindprod.com/jgloss/cgi.html
> --
> Canadian Mind Products, Roedy Green.
> http://mindprod.com Again taking new Java programming contracts.
|
|
0
|
|
|
|
Reply
|
Darren
|
9/6/2005 9:43:21 AM
|
|
"Dag Sunde" <me@dagsunde.com> wrote in message
news:KvbTe.5156$qE.1160910@juliett.dax.net...
> "Darren" <Daz@devslashnul.net> wrote in message
> news:JK3Te.3104$zw1.798@newsfe2-gui.ntli.net...
> >
> > "Dag Sunde" <me@dagsunde.com> wrote in message
> > news:893Te.5135$qE.1158696@juliett.dax.net...
> <snipped />
> >> Is this an Applet, and are you trying to access another site that
> >> the one hosting your Applet?
> >>
> >> If so, you need to sign your Applet. There is no way you can do
> >> cross-domain communication in an applet without either signing it,
> >> or manually editing each users java.policy file.
> >
> > Yes, wel the idea is this
> > A public site hosts my web page but on this site there is a link to a
> > members only site which resides on a box i am hosting. my public web
page
> > is
> > on a server that offers no server side scripting or i would knock
together
> > a
> > server side script to do the job so i'm stuck with client side Now i
> > don't
> > think flash or javascript can do what i want so i'm stuck with using
java
> > which isn't a bad thing because i happen to like the language.
> > Now where was I?
> > The public web page will have a link on it which will only show when my
> > members only server is up. the making the link work or not work is easy
> > but
> > the checking of server status is a tougher option so i should do it with
> > an
> > applet if possible. so what do i do with users java policies and or how
do
> > i
> > get this script signed?
>
> Google for it!
>
> You can also search this NG for several threads on the subject.
> Here is a couple to get you started.
>
<http://groups.google.no/group/comp.lang.java.programmer/browse_thread/threa
d/7030468c124d26ac/165ce09248660543>
>
http://groups.google.no/group/comp.lang.java.programmer/browse_frm/thread/b05fbae81cba09d9/f3655aec2a6c7387#f3655aec2a6c7387
>
> A fair warning, thou... This is *not* the easiest part of Java to dive
into.
> The documentation on this subject is very abstract and vague. (IMO).
Your not kidding. Why is it that what should be a simple request turns out
to be complicated beyond beleif?
>
> --
> Dag.
>
>
|
|
0
|
|
|
|
Reply
|
Darren
|
9/6/2005 10:26:20 AM
|
|
On Tue, 06 Sep 2005 10:26:20 GMT, Darren wrote:
> Why is it that what should be a simple request turns out
> to be complicated beyond beleif?
'What is the meaning of life?' is a simple question..
[ Follow-Ups to this post, set to c.l.j.p. only ]
--
Andrew Thompson
physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
"We are about to attempt a crash landing. Please extinguish all
cigarettes.."
Laurie Anderson 'From The Air'
|
|
0
|
|
|
|
Reply
|
Andrew
|
9/6/2005 10:40:54 AM
|
|
"Andrew Thompson" <SeeMySites@www.invalid> wrote in message
news:1neeep2ur3zjd.1vl5ju6zaojtu$.dlg@40tude.net...
> On Tue, 06 Sep 2005 10:26:20 GMT, Darren wrote:
>
> > Why is it that what should be a simple request turns out
> > to be complicated beyond beleif?
>
> 'What is the meaning of life?' is a simple question..
42
>
> [ Follow-Ups to this post, set to c.l.j.p. only ]
>
> --
> Andrew Thompson
> physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
> "We are about to attempt a crash landing. Please extinguish all
> cigarettes.."
> Laurie Anderson 'From The Air'
|
|
0
|
|
|
|
Reply
|
Daz (100)
|
9/6/2005 11:28:49 AM
|
|
> > > I still remember the software lifecylce yet a large quantity of
software
> > houses and thier programmers don't use it.
> >
> > There is no *the* software lifecycle, there are many, all reflecting the
> > methodology you pick or believe in.
> I spent three years in university learning *The* software lifecycle and
not
> *A* software lifecycle but that was many moons ago. A lot could have
> ha[[ened since then.
Universities are not immune from hiring incompetent teachers. I've reviewed
plenty of books (many written by uni profs) for a living, and some of those
written by so-called professors have been shameful.
> Software companies will justify that software will not fall apart like
badly
> designed buildings but if that software is controlling aricraft or life
> support machines the EEEEEEEEK
Obviously flawed software will have difficulty crushing people to death, but
flawed software can have a similar *financial* effect: small fortunes that
have to be written off. In the public sector, not a year goes by without
some high-profile IT disaster costing not hundreds of thousands of dollars
or pounds, but millions, often tens or hundreds of millions. That's your and
my tax money being thrown out the window....
I think it's high time for legislation regulating our industry. We've been
getting away with murder so far.
|
|
0
|
|
|
|
Reply
|
nul32 (392)
|
9/6/2005 3:48:07 PM
|
|
Darren wrote:
> "Andrew Thompson" <SeeMySites@www.invalid> wrote in message
> news:1neeep2ur3zjd.1vl5ju6zaojtu$.dlg@40tude.net...
>> On Tue, 06 Sep 2005 10:26:20 GMT, Darren wrote:
>>
>>> Why is it that what should be a simple request turns out
>>> to be complicated beyond beleif?
>>
>> 'What is the meaning of life?' is a simple question..
> 42
No, this is the answer to the "ultimate question of life, the universe and
everything."
--
Virgil
|
|
0
|
|
|
|
Reply
|
vjg (272)
|
9/6/2005 6:35:46 PM
|
|
"Darren" <Daz@devslashnul.net> wrote in message
news:N6FSe.1616$741.659@newsfe6-gui.ntli.net...
> Hello. I need to use java to check if a server is up and i am
> trying to do
> it with sockets but i understand there are security issues. The
> aim is this.
> There is a members only site that sometimes goes down for
> mainetenence
> This applet needs to contact this site to get a response, any
> response and
> if it does then the site is up. if not then the site is down.
> Anyone know
> how I can acheive this>
> TIA
ping should do it.
|
|
0
|
|
|
|
Reply
|
Joan
|
9/6/2005 11:58:25 PM
|
|
"Joan" <Joan@nospam.invalid> wrote in message
news:lr-dnRpAm9u_sIPeRVn-1Q@comcast.com...
>
> "Darren" <Daz@devslashnul.net> wrote in message
> news:N6FSe.1616$741.659@newsfe6-gui.ntli.net...
> > Hello. I need to use java to check if a server is up and i am
> > trying to do
> > it with sockets but i understand there are security issues. The
> > aim is this.
> > There is a members only site that sometimes goes down for
> > mainetenence
> > This applet needs to contact this site to get a response, any
> > response and
> > if it does then the site is up. if not then the site is down.
> > Anyone know
> > how I can acheive this>
> > TIA
>
> ping should do it.
>
From Java?
|
|
0
|
|
|
|
Reply
|
Darren
|
9/7/2005 12:47:32 AM
|
|
a surprising omission from java, I always thought. But thinking about it
more, IIRC you need root privileges in unix to create raw packets, so that's
probably why.
Dave Milne, Scotland
'91 Grand Wagoneer, '99 TJ
"Darren" <Daz@devslashnul.net> wrote in message
news:EMqTe.7349$VB1.5969@newsfe1-gui.ntli.net...
> > ping should do it.
> >
> From Java?
>
>
|
|
0
|
|
|
|
Reply
|
Dave
|
9/7/2005 1:54:55 AM
|
|
On 7-9-2005 2:47, Darren wrote:
> "Joan" <Joan@nospam.invalid> wrote in message
> news:lr-dnRpAm9u_sIPeRVn-1Q@comcast.com...
>
>>"Darren" <Daz@devslashnul.net> wrote in message
>>news:N6FSe.1616$741.659@newsfe6-gui.ntli.net...
>>
>>>Hello. I need to use java to check if a server is up and i am
>>>trying to do
>>>it with sockets but i understand there are security issues. The
>>>aim is this.
>>>There is a members only site that sometimes goes down for
>>>mainetenence
>>>This applet needs to contact this site to get a response, any
>>>response and
>>>if it does then the site is up. if not then the site is down.
>>>Anyone know
>>>how I can acheive this>
>>>TIA
>>
>>ping should do it.
>>
>
> From Java?
>
>
Yep, in Java 5.0 (aka 1.5.0) you can use InetAddress.isReachable(). This
sends ICMP ECHO requests to the address. [Most (all?) ping command
implementations use the same ICMP requests to check if the address is
reachable.]
<http://java.sun.com/j2se/1.5.0/docs/api/java/net/InetAddress.html#isReachable(int)>
--
Regards,
Roland de Ruiter
` ___ ___
`/__/ w_/ /__/
/ \ /_/ / \
|
|
0
|
|
|
|
Reply
|
Roland
|
9/7/2005 9:56:44 AM
|
|
"Roland" <roland@phony.biz> wrote in message
news:431eb95a$0$11069$e4fe514c@news.xs4all.nl...
> On 7-9-2005 2:47, Darren wrote:
>> "Joan" <Joan@nospam.invalid> wrote in message
>> news:lr-dnRpAm9u_sIPeRVn-1Q@comcast.com...
>>
>>>"Darren" <Daz@devslashnul.net> wrote in message
>>>news:N6FSe.1616$741.659@newsfe6-gui.ntli.net...
>>>
>>>>Hello. I need to use java to check if a server is up and i am
>>>>trying to do
>>>>it with sockets but i understand there are security issues. The
>>>>aim is this.
>>>>There is a members only site that sometimes goes down for
>>>>mainetenence
>>>>This applet needs to contact this site to get a response, any
>>>>response and
>>>>if it does then the site is up. if not then the site is down.
>>>>Anyone know
>>>>how I can acheive this>
>>>>TIA
>>>
>>>ping should do it.
>>>
>>
>> From Java?
>>
>>
> Yep, in Java 5.0 (aka 1.5.0) you can use InetAddress.isReachable(). This
> sends ICMP ECHO requests to the address. [Most (all?) ping command
> implementations use the same ICMP requests to check if the address is
> reachable.]
>
> <http://java.sun.com/j2se/1.5.0/docs/api/java/net/InetAddress.html#isReachable(int)>
As long as the OP is restricted to the Applet's sandbox this doesn't help
much, since it is the permission problem with cross-domain access from
an applet he is truggling with...
I presume here that Java 5.0's "InetAddress.isReachable()" will trigger
a permission denied, just as opening an URL() will...?
--
Dag.
|
|
0
|
|
|
|
Reply
|
Dag
|
9/7/2005 10:04:29 AM
|
|
"Dave Milne" <jeep@_nospam_milne.info> wrote in message
news:PLrTe.103889$G8.94491@text.news.blueyonder.co.uk...
> a surprising omission from java, I always thought. But thinking about it
> more, IIRC you need root privileges in unix to create raw packets, so
that's
> probably why.
I have root privileges :)
>
> Dave Milne, Scotland
> '91 Grand Wagoneer, '99 TJ
>
> "Darren" <Daz@devslashnul.net> wrote in message
> news:EMqTe.7349$VB1.5969@newsfe1-gui.ntli.net...
>
> > > ping should do it.
> > >
> > From Java?
> >
> >
>
>
|
|
0
|
|
|
|
Reply
|
Darren
|
9/7/2005 11:01:53 AM
|
|
"Dave Milne" <jeep@_nospam_milne.info> wrote in message
news:PLrTe.103889$G8.94491@text.news.blueyonder.co.uk...
>a surprising omission from java, I always thought. But thinking
>about it
> more, IIRC you need root privileges in unix to create raw
> packets, so that's
> probably why.
>
> Dave Milne, Scotland
> '91 Grand Wagoneer, '99 TJ
>
> "Darren" <Daz@devslashnul.net> wrote in message
> news:EMqTe.7349$VB1.5969@newsfe1-gui.ntli.net...
>
>> > ping should do it.
>> >
>> From Java?
So tell you boss you can't do it without this privilege and make
her decide!
|
|
0
|
|
|
|
Reply
|
Joan
|
9/7/2005 11:54:02 PM
|
|
"Joan" <Joan@nospam.invalid> wrote in message
news:vqadnZ2dnZ3I94GFnZ2dnQHggt6dnZ2dRVn-yp2dnZ0@comcast.com...
>
> "Dave Milne" <jeep@_nospam_milne.info> wrote in message
> news:PLrTe.103889$G8.94491@text.news.blueyonder.co.uk...
> >a surprising omission from java, I always thought. But thinking
> >about it
> > more, IIRC you need root privileges in unix to create raw
> > packets, so that's
> > probably why.
> >
> > Dave Milne, Scotland
> > '91 Grand Wagoneer, '99 TJ
> >
> > "Darren" <Daz@devslashnul.net> wrote in message
> > news:EMqTe.7349$VB1.5969@newsfe1-gui.ntli.net...
> >
> >> > ping should do it.
> >> >
> >> From Java?
>
> So tell you boss you can't do it without this privilege and make
> her decide!
I'm not a she. :)
>
|
|
0
|
|
|
|
Reply
|
Darren
|
9/8/2005 2:36:35 PM
|
|
|
45 Replies
140 Views
(page loaded in 0.416 seconds)
Similiar Articles: HP LaserJet 3015 - comp.sys.mac.apps>> If you can't "see" it, perhaps your system is have a problem with the >> WiFi network. According HP's site, this printer should just show up a= s >> it speaks Bonjour ... A problem in IPsec - comp.unix.solarisWe set up the Ipsec configuration on the Solaris server, using the normal procedure ... Seeing the _other_ side at the same time is far more helpful in > figuring out what's ... disk not responding to selection - comp.unix.solarisPower up and see if a miracle occurred! No miracle? Replace the disk! Restore your backup. If you have no backup, now you understand why you should have made them ... Slow string search/fast binary search - comp.lang.asm.x86 ...My program is searching small blocks of ordered pointers to see if a given pointer is ... I assumed a single repne scasd instruction would be faster than setting up a ... A splash screen - comp.lang.java.guiSplashPanel extends JPanel and contains all of the components making up the ... contributions and may include this or an improved version in his pending site update. See ... (sh/bash) How to check for a string matching -*? - comp.unix.shell ...Currently, I use case/esac to test to see if a string starts with a dash: case $1 ... 0 The offset 0 (first character in string) can trip you up though, the bash ... Keyboard Input - comp.lang.asm.x86The raw scancode is looked up in a table and converted to an ascii code, in the ... :) I recall seeing a nicely-commented int 9 handler somewhere on the Webster site - in ... Getting EHOSTUNREACH -- No route to host error while sending a UDP ...> > > > > > My IPv4-v6 dual stack is up properly. I can see a link local addr= ess > > > > > if I give ifShow command. > > > > > I am trying to connect to an IPv6 server at some ... instructions on how to perform an IOS upgrade on a Catalyst 6500 ...... and error, but > would like to see if there is a document that explains the best > practices, and my searches didn't come up with ... anyone know of a link on Cisco's site ... show a wait box - comp.lang.javascriptIf I see such a thing I immediately go elsewhere as the thing that I must wait to ... we are into an Intranet You did *not* state that this is an intranet site up front. recv-Q and Send-Q error in netstat - comp.unix.solarisHi all, We need to figure out some problem due to network latency between two sites and run netstat to see if Recv-Q and Send-Q are filling up, but we... ATAPI CD-ROM drive in a SCSI system - comp.periphs.scsi... BIOS screen, with the red highlights screen coming up ... It doesn't seem to be an option that I can see. ... by another company which does not have support web site ... Activehome Software to CM11A - comp.home.automationI was able, after about 10 minutes of waiting, to bring up Task Manager to see what was happening. The program x10com32.exe was taking 99%+ of the CPU. 1520 Plotter - Where to find pen replacements... - comp.sys.cbm ...... somewhere, I couldn't find any at Radio Shack web site. ... with the RS and Atari printers...but you can open it up ... I could take it to a local rat shack and see if they ... glTexSubImage2D slower than glTexImage2D - comp.graphics.api ...You can test by checking to see if the bug texture is resident -- it may not be when you think it is. To speed up texture loads: BGR(A) format, unsigned bytes, or maybe ... CheckSite.us - Check to see if a website is down for you or for ...CheckSite.us is a simple service that allows a user to check to see if a site is actually ... we cannot access, we'll continue trying the website every 15 minutes for up to ... How to Test a Website to See if It Is Working | eHow.comThe computer sends up to four ping queries to the website of your choice. If the website is functioning, you see four replies revealing the website's IP address and the ... 7/29/2012 6:33:12 AM
|