aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes Applets & Sockets .The Security Issue Of JAVA. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Applets & Sockets .The Security Issue Of JAVA." Watch "Applets & Sockets .The Security Issue Of JAVA." New topic
Author

Applets & Sockets .The Security Issue Of JAVA.

Neeraj Thakkar
Ranch Hand

Joined: Dec 06, 2000
Posts: 80
Due to Security Reasons the Applets can only make a socket connection to the host from where they are loaded.The Client code underneath is an applet which tries to make a socket connection to the host from where it is loaded but the connection could not be established. A SecurityException is thrown.
A Untrusted Appplet can make the connection to the host from where it is loaded. But here in this case it is not able to make the connection what's the reason.
This program is working perfectly fine when the html file is opened in browser on the same machine but, when I open the html file on a remote system the applet is loaded properly but the connection is not established.
If I change the applet to a application then there is no problem but that is not the solution.
Is there any need to use the Security Manager here if yes then what should I do.
Source Code
Client.java
--------------------------------------------------------------

Server.java
---------------------------------------------------------------------------

HTML File
-------------------------------------------------------------------------------------------
< html>
< body>
< applet code="Client" codebase="\\Impactserver\Neeraj\" height=400 width=400>
< /applet>
< /body>
< /html>

Can anyone help.
Neeraj Thakkar

------------------
I added spaces to allow the html to Show and ubb code tags for easier reading

[This message has been edited by Carl Trusiak (edited February 01, 2001).]


Neeraj Thakkar<br />"Try to get what you like,Else you will be forced to like what you get."
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
You are correct, an Applet can only connect to the machine where the Applet code originated. The easiest way to ensure the Applet is going back to the same server is to use
s=new Socket(this.getCodeBase().getHost(),7384);
instead of
s=new Socket("Impactserver",7384);
------------------
Hope This Helps
Carl Trusiak
[This message has been edited by Carl Trusiak (edited February 01, 2001).]


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
Neeraj Thakkar
Ranch Hand

Joined: Dec 06, 2000
Posts: 80
Hi Carl,
Thanks for the reply. I am now going to test what u have suggested. You are an active participant in this forum so i hope to listen from u in the future also.
Thanks again.
Neeraj Thakkar
Ranch Hand

Joined: Dec 06, 2000
Posts: 80
Hi Carl,
I tried out your suggested way of making a connection but it too didn't worked. The problem still remains the same.
Any other way of doing it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Applets & Sockets .The Security Issue Of JAVA.