Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

sockets and security violation

Posted on 1997-11-13
3
Medium Priority
?
229 Views
Last Modified: 2010-04-16
I have a java application which is running outside IIS on a server
  (the server allow just applet's downloading) and when I'm tryng to
  connect to the server with a java application on the client side
  everything works well. The lines are:

   s=new Socket(name,1183);
   System.out.println("OK");

   on client's side ( name is the valid host name )

   However when I'm turning this application into an applet, when
   I'm placing it on the server (the root diretory of IIS,
   D:\InetPub\wwwroot ) and when I'm opening a connection to the
  .html that contain it, the applet is retrieve but I have a secu-
   rity violation for these lines:

   InetAddress st=InetAddress.getLocalHost();
   s=new Socket(st,1183);

   ( I don't believe I can open it with the direct name from an
    applet)

   The java application run in the directory
   D:\InetPub\wwwroot\java

   any idea?
0
Comment
Question by:jfbe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 4

Expert Comment

by:rembo
ID: 1230482

The problem is that the Security Manager in Netscape
(or IE for that matter) will *only* allow you to
connect back to the system that you were loaded
from.  

The only exception too this rule is the showDocument()
method.  This causes the browser to load another document
which can be from anywhere.  

So, you will have to move that application to the same
server as your browser or you will have to load the applet
from the same host as the server.

-Tony

0
 

Author Comment

by:jfbe
ID: 1230483

 No, as I explained in my question my applet is coming from the same server where the application is running. I got a clue when I
output to the screen the result of:

InetAddress st=InetAddress.getLocalHost();
 st.toString() do not give me the host name but something that looks like my email.
I'll try with getDocumentBase().getHost()) later but it wasn't
the reason.
0
 
LVL 4

Accepted Solution

by:
rembo earned 200 total points
ID: 1230484

getLocalHost() will not give you the right answer in an
applet.

getCodeBase() or getDocumentBase().getHost() will do
what you want:

Socket s = (getCodeBase().getHost(), port);

That will do it.


0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question