This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Applets & Sockets .The Security Issue Of JAVA.  RSS feed

 
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).]
 
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!