Java Forum / General / May 2007
How to communicate from HTML page with an IP which is not the web-server?
DavidNorep - 12 May 2007 16:36 GMT I want that when the visitor in my website clicks on a particular button - text will be sent to a certain port at a certain IP, which is not the web server.
Is Java the only technology to do this (except Microsoft technologies, which I am not familiar with)?
If yes - must I have an applet, even though the Java code does not need a GUI? I assume that the applet may be invisible.
I understand that the applet will face security obstacles in both sides, and that it should be signed. Does it cost money to have a signed applet?
Daniel Dyer - 12 May 2007 17:24 GMT > I want that when the visitor in my website clicks on a particular > button - text will be sent to a certain port at a certain IP, which is > not the web server. > > Is Java the only technology to do this (except Microsoft technologies, > which I am not familiar with)? You can do it with Flash, in which case it's probably easiest if the button itself is the Flash movie. Flash is more likely to be installed on the average user's PC than Java.
Better still, depending on your constraints, you might be able to do it the AJAX way with JavaScript and XMLHttpRequest (I think the server that you connect to would have to speak HTTP).
> If yes - must I have an applet, even though the Java code does not > need a GUI? I assume that the applet may be invisible. > > I understand that the applet will face security obstacles in both > sides, and that it should be signed. Does it cost money to have a > signed applet? You can create a self-signed applet for free. The problem is that the browser will put up a warning and a prompt because it can't validate that you are who you say you are.
If you buy a certificate from a third party, they will be vouching for you because you will have had to have identified yourself to them. The browser implicitly trusts the certificate issuers (because their root certificates are already installed in the browser), and won't need to prompt the user.
Dan.
 Signature Daniel Dyer https://watchmaker.dev.java.net - Evolutionary Algorithm Framework for Java
DavidNorep - 12 May 2007 17:40 GMT > You can do it with Flash, in which case it's probably easiest if the > button itself is the Flash movie. Flash is more likely to be installed on > the average user's PC than Java. I do not know Flash, so this is not an option for me.
> Better still, depending on your constraints, you might be able to do it > the AJAX way with JavaScript and XMLHttpRequest (I think the server that > you connect to would have to speak HTTP). I thought that with HTTP I can communicate only with the server from which the HTML page was downloaded. Am I wrong?
I am ready to study Javascript & AJAX. Can I use the XMLHttpRequest object to send text to a specific port in another computer?
> You can create a self-signed applet for free. The problem is that the > browser will put up a warning and a prompt because it can't validate that [quoted text clipped - 5 lines] > certificates are already installed in the browser), and won't need to > prompt the user. Do you know the price of a third party certificate?
Daniel Dyer - 12 May 2007 18:11 GMT >> You can do it with Flash, in which case it's probably easiest if the >> button itself is the Flash movie. Flash is more likely to be installed [quoted text clipped - 9 lines] > I thought that with HTTP I can communicate only with the server from > which the HTML page was downloaded. Am I wrong? I don't know. Probably best to ask on comp.lang.javascript. There may well be a similar restriction as with applets. I believe that there is such a thing as "signed JavaScript".
> Do you know the price of a third party certificate? No, but Thawte and Verisign do. Thawte also have a "personal e-mail certificate" scheme which gives you a free, properly authenticated certificate for use with e-mails. This can be used to sign code as well. I can't remember how it differs from the regular pay-for certificate.
Dan.
 Signature Daniel Dyer https://watchmaker.dev.java.net - Evolutionary Algorithm Framework for Java
Andrew Thompson - 12 May 2007 18:35 GMT >> I want that when the visitor in my website clicks on a particular >> button - text will be sent to a certain port at a certain IP, which is >> not the web server. ...
>> I understand that the applet will face security obstacles in both >> sides, and that it should be signed. Does it cost money to have a >> signed applet? > >You can create a self-signed applet for free. The problem is that the >browser will put up a warning and a prompt As an end user, I see that as a benefit.
>...because it can't validate that >you are who you say you are. No. It will put up a security warning even if the digital certificate has been verified by Thawte or Verisign.
The only difference is in the style of the dialog. The dialog will note that the self-signed certificate 'cannot be verified by a trusted authority' or some such, but *no* certificate gives an applet automatic (unchallenged) unrestricted access to the local system.
 Signature Andrew Thompson http://www.athompson.info/andrew/
Daniel Dyer - 12 May 2007 18:40 GMT >> ...because it can't validate that >> you are who you say you are. [quoted text clipped - 9 lines] > gives an applet automatic (unchallenged) > unrestricted access to the local system. Yes, I was thinking of the way server certificates work. They don't prompt you if everything is OK. It's been a while since I signed an applet.
Dan.
 Signature Daniel Dyer https://watchmaker.dev.java.net - Evolutionary Algorithm Framework for Java
DavidNorep - 13 May 2007 07:07 GMT I am still not sure if I must have an applet, even though the Java code does not need a GUI? I assume that the applet may be invisible.
Dag Sunde - 13 May 2007 08:33 GMT > I am still not sure if I must have an applet, even though the Java > code does not > need a GUI? I assume that the applet may be invisible. As Daniel say, you can do it with AJAX: * You send an XMLHTTP call to the server. * A server-script do the connection to the external port you want (Servers don't have the cross-domain security restriction). * When the server script get the response from your external call, it returns HTML or XML to your JavaScript in your original page.
If you want to do it With an Applet, the Applet must be signed (either with a self-signed or commercial certificate) to be able to connect to anything else than the server the Applet originated from.
The only difference between a self-signed and a commercial certificate is the warning message that appears when the system ask the user for permission to run this signed Applet. Priviledges _will_ be granted to both kinds if the user say so.
The Applet may be invisible or have a GUI. The visibility of the Applet does not influence its behaviour.
Just one point to be aware of: If you call the (signed) Applet method that do the priviledged task from a Javascript statement on the page, the method will fail with a security exception. The JRE will notice that the call came from a non-privilegded system (in this case JavaScript).
To walk around this, call a method in the Applet that only set a flag, indicating that you want the method executed, and make your Applet poll for this flag regularly.
 Signature Dag.
DavidNorep - 13 May 2007 10:37 GMT > As Daniel say, you can do it with AJAX: > * You send an XMLHTTP call to the server. > * A server-script do the connection to the external port you > want (Servers don't have the cross-domain security restriction). > * When the server script get the response from your external call, > it returns HTML or XML to your JavaScript in your original page. Maybe I was not clear enough - I do not want that the communication will pass through the HTTP server, but directly between the two home computers. So I assume that XMLHTTPRequest is not a solution.
> If you want to do it With an Applet, ... So I want to do this in Java. I understand that you say that doing it in Java means doing it with an applet, which may be invisible.
> Just one point to be aware of: > If you call the (signed) Applet method that do the priviledged [quoted text clipped - 5 lines] > a flag, indicating that you want the method executed, and make > your Applet poll for this flag regularly. I thought that the HTML page is loaded and then the init() method of the applet is invoked. Can you invoke from Javascript any public method in the applet?
Thanks.
Dag Sunde - 13 May 2007 19:01 GMT >> As Daniel say, you can do it with AJAX: >> * You send an XMLHTTP call to the server. [quoted text clipped - 23 lines] > the applet is invoked. Can you invoke from Javascript any public > method in the applet? Yes, You can...
Something like this:
if ( document.getElementById('yourAppletId') ) { var myApplet = document.getElementById('yourAppletId'); myApplet.yourmethod(); }
 Signature Dag.
Richard Maher - 14 May 2007 01:07 GMT Hi David,
> I want that when the visitor in my website clicks on a particular > button - text will be sent to a certain port at a certain IP, which is [quoted text clipped - 9 lines] > sides, and that it should be signed. Does it cost money to have a > signed applet? Not completely sure what everyone else is going on about in the thread (or I've probably completely misunderstood your question) but my answer to you is "The Java option works, and is straight-forward to implement".
If your Applet connects back to the same server as the codebase (as specified in the <object> tag) then is does not need to be signed. Just stick the JAR file on whatever server you want to connect back to. If it's run-time determination of the target IP address that you're after, then you're on your own :-)
So as not to interfere with the format of the web-page that is hosting *my* Applet, I pop-up seperate modal dialog boxes when I wish to interact with the User. (Username/Password and then a Welcome panel) For security, I keep the network connection up only while the hosting page (this includes all sub-pages in sub-Frames) is displayed.
With the Microsoft/Eolas dispute (some?) Applets on IE result in the "Click to activate and use this control" message, but I think what SUN refers to as blind-applets (what we both wish to use) do not suffer from this restriction. (And there are several published solutions/work-arounds for this anyway)
Now, if whatever it is your hosting, on this "certain port and certain IP" is not a web server then I have no idea why anyone would recommend going the AJAX route. When will people start thinking outside the box on this one? If you want to send HTML pages with embedded images/objects then HTTP is absolutely the mut's nuts! As an application-middleware protocol it is a complete pile of pooh! I suppose the sad fact is that "a.n.other mono-lingual Web-Server" is the *only* application-server available on most architectures :-(
Cheers Richard Maher
PS. I love the Java Applet approach primarily 'cos of it's cross-platform appeal and 'cos you don't have to have things signed to achieve my aims, but I am also interest in the .NET solution. Can anyone point to good web-site for converting a Java Applet into a .NET compatible, browser resident, ActiveX Socket calling "thingy"? In other words, I want to do a Socket and Connect back to a server using whatever Microsoft's solution is; can someone please point me to an example? (I know it's the wrong group but I'm sure someone here must know)
Andrew Thompson - 14 May 2007 05:06 GMT ..
>> ...signed applet? ...
>If your Applet connects back to the same server as the codebase ... This applet needs to communicate with a /foreign/ server.
 Signature Andrew Thompson http://www.athompson.info/andrew/
Luc The Perverse - 14 May 2007 05:21 GMT > . >>> ...signed applet? > .. >>If your Applet connects back to the same server as the codebase ... > > This applet needs to communicate with a /foreign/ server. I believe this is deliberately disallowed for security purposes.
You might have better luck with JNLP.
-- LTP
:) Andrew Thompson - 14 May 2007 08:14 GMT >> . >>>> ...signed applet? [quoted text clipped - 4 lines] > >I believe this is deliberately disallowed for security purposes. Sandoxed applet - yes. Signed and trusted applet - no.
A trusted applet can do almost anything short of System.exit() (which is something that does not occur to most people as being disallowed in the first place).
>You might have better luck with JNLP. Huhh.. Cannot quite believe (looking back over this thread), not only was that the first time web start was mentioned, but that *I* wasn't the first to mention it. ;-)
 Signature Andrew Thompson http://www.athompson.info/andrew/
Richard Maher - 14 May 2007 10:35 GMT Hi Andrew, Luc
> >You might have better luck with JNLP. > > Huhh.. Cannot quite believe (looking back over this thread), > not only was that the first time web start was mentioned, > but that *I* wasn't the first to mention it. ;-) Yep, I reakon you're right. Why should the OP get the Antartic Blue Super Sports-Wagon when you guys can sell him The Wagonqueen Family Truckster? (Throwing in the metallic-pea paint for no extra cost was a nice touch)
Regards Richard Maher
> >> . > >>>> ...signed applet? [quoted text clipped - 16 lines] > not only was that the first time web start was mentioned, > but that *I* wasn't the first to mention it. ;-) Luc The Perverse - 14 May 2007 14:50 GMT >>You might have better luck with JNLP. > > Huhh.. Cannot quite believe (looking back over this thread), > not only was that the first time web start was mentioned, > but that *I* wasn't the first to mention it. ;-) Wow! I may have actually helped on USENET! That's nice ;)
-- LTP
:) Richard Maher - 14 May 2007 08:50 GMT Hi Luc,
> I believe this is deliberately disallowed for security purposes. *What* do you believe is deliberately disallowed for security purposes?
Cheers Richard Maher
> > . > >>> ...signed applet? [quoted text clipped - 11 lines] > > :) Sherm Pendley - 14 May 2007 09:00 GMT >> > This applet needs to communicate with a /foreign/ server. >> >> I believe this is deliberately disallowed for security purposes. > > *What* do you believe is deliberately disallowed for security purposes? Communicating with a foreign server. See what happens when you post upside- down? You can even confuse yourself that way.
sherm--
 Signature Web Hosting by West Virginians, for West Virginians: http://wv-www.net Cocoa programming in Perl: http://camelbones.sourceforge.net
Richard Maher - 14 May 2007 08:45 GMT Hi Andrew,
> This applet needs to communicate with a /foreign/ server. I re-read this thread twice and cannot see how you attribute this requirement to the OP, or your definition of /foreign/.
Cheers Richard Maher
> . > >> ...signed applet? > .. > >If your Applet connects back to the same server as the codebase ... > > This applet needs to communicate with a /foreign/ server. Sherm Pendley - 14 May 2007 08:57 GMT > Hi Andrew, >> >> This applet needs to communicate with a /foreign/ server. > > I re-read this thread twice and cannot see how you attribute this > requirement to the OP The subject says "an IP which is not the web-server" - looks pretty clear to me...
sherm--
 Signature Web Hosting by West Virginians, for West Virginians: http://wv-www.net Cocoa programming in Perl: http://camelbones.sourceforge.net
Richard Maher - 14 May 2007 09:19 GMT Hi Sherm,
> The subject says "an IP which is not the web-server" - looks pretty clear > to me... So is that *your* definition of a foreign server? Andrew's? or did the OP discuss this on some post that my newsreader can't see?
"codebase" has absolutely bugger-all to do with "web-server"! If any of you would try to string entire sentences together then maybe someone might be able to pin you down on whatever it is you're claiming to be a restriction.
*I* say "Without the need to be signed, your Applet can connect to any server, and certainly a server other than the web server, as long as that is where the codebase parameter says the Archive (or class files) live". And it certainly wasn't explicitly clear to me that the OP's requirements could not be satisfied with this scenario.
So, once again, please tell me *what* has become "pretty clear" to you as a result of "an IP which is not the web-server"? Are you aware that you can also use FTP as a protocol for your Applets? (And I for one am currently developing a lightweight Applet uploader that doesn't have the normal bloated elephant carcass of a normal http web-server.)
Cheers Richard Maher
> > Hi Andrew, > >> [quoted text clipped - 7 lines] > > sherm-- Sherm Pendley - 14 May 2007 09:55 GMT Upside down. Obviously with intent to obfuscate.
>> > Hi Andrew, >> >> [quoted text clipped - 7 lines] > > So, once again, please tell me *what* has become "pretty clear" to you That you're being absurdly pedantic. Yeah, sure you *can* serve an applet from an FTP server - do you seriously think the OP is actually doing so?
Grow up. Your pedantry impresses no one.
sherm--
 Signature Web Hosting by West Virginians, for West Virginians: http://wv-www.net Cocoa programming in Perl: http://camelbones.sourceforge.net
DavidNorep - 14 May 2007 11:41 GMT What is OP? Does it refer to me - the originator of this thread? (English is not my mother tongue).
I am sorry if I was not very clear - I want that the applet will be downloaded from some web-server and communicate with a program in another non-server computer.
I like Java but I am worried about the hassles of installing the JRE, the security issues and also general problems, for example, now I cannot run applets on IE7 with XP (but can run them on Firefox) because I get an error message that "Several Java Virtual Machines running the same ..."; searching the web for this error I found that during the last years people often complained about it. I complained about it and reinstalled IE7 and JRE but it did not help. BTW, I noticed that Internet options/ General/Browsing History/ Settings/View Objects has 3 JRE1.6 objects. Is this a problem? Manuall deleting them did not help either.
Andrew Thompson - 14 May 2007 12:20 GMT >What is OP? 'Original Poster'.
>..Does it refer to me - the originator of this thread? Yes.
>(English is not my mother tongue). Thanks for your efforts - I do not know any other language.
>I am sorry if I was not very clear - I want that the applet will be >downloaded from some web-server and communicate with a program in >another non-server computer. Can you communicate between a Java app. (of any variety) and your.. 'port at a certain IP' at the moment?
>I like Java but ... ...
>I am worried about the hassles of installing the JRE, Most computers come with it. Most other PCs - the user either will not, or cannot, install Java. Though that being said ..*.
>the security issues and also general problems, For the developer, perhaps in some ways. On the other hand, if end users have the confidence that the Java Plug-In is secure and safe, and updated promptly when found otherwise, that helps encourage them to install/enable it.
>...for example, now I cannot run applets .. Applets always have, and always will, be problematic. Best avoid them completely.
I recommend you go for an application launched using web start. It will still need to be signed by you, and trusted by the end user, but that code signing does not have to cost anything.
Here are some web start examples.. A self signed application. <http://www.physci.org/jws/#giffer> A (sandboxed) example of both an applet and application. <http://www.physci.org/jws/#jtest>
As an added bonus, once the end user has any web start enabled version of the Java Plug-In installed, web start launch can also .. * ensure minimum Java versioning, complete with guiding some users through an easy update process, if needed.
 Signature Andrew Thompson http://www.athompson.info/andrew/
douggunnoe@gmail.com - 16 May 2007 07:55 GMT "I am sorry if I was not very clear - I want that the applet will be downloaded from some web-server and communicate with a program in another non-server computer."
This link might help.
http://forum.java.sun.com/thread.jspa?threadID=617789&messageID=3453765
Would the restrictions of an applet forbid it from writing to a port of another application that is not on a web server?
I'm not sure, but it seems I have seen Applet IRC clients.
Sherm Pendley - 16 May 2007 08:19 GMT > Would the restrictions of an applet forbid it from writing to a port > of another application that is not on a web server? The restriction is on addresses, not ports.
What's forbidden is to connect to an address other than the one from which the applet was loaded. The applet can, however, connect to any port at that address.
> I'm not sure, but it seems I have seen Applet IRC clients. That's allowed, if the IRC server is on the machine from which the applet was loaded.
sherm--
 Signature Web Hosting by West Virginians, for West Virginians: http://wv-www.net Cocoa programming in Perl: http://camelbones.sourceforge.net
Lew - 16 May 2007 14:07 GMT >> Would the restrictions of an applet forbid it from writing to a port >> of another application that is not on a web server? [quoted text clipped - 9 lines] > That's allowed, if the IRC server is on the machine from which the applet > was loaded. Meaning that the applet can communicate with any host if the communication is mediated via its own server. Maybe the answer for the OP is to use server-to-server communication as a proxy.
 Signature Lew
Dag Sunde - 16 May 2007 14:58 GMT >>> Would the restrictions of an applet forbid it from writing to a port >>> of another application that is not on a web server? [quoted text clipped - 13 lines] > communication is mediated via its own server. Maybe the answer for > the OP is to use server-to-server communication as a proxy. The answer to the OP is to sign his Applet!
Then the Applet can contact any server on any port it like regardless of its origin, as long as the user accepted the certificate.
 Signature Dag.
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|