• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Applets & Sockets .The Security Issue Of JAVA.

 
Neeraj Thakkar
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Neeraj Thakkar
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic