Help coderanch get a
new server
by contributing to the fundraiser
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Applets & Sockets .The Security Issue Of JAVA.

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic