[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: java applet problem

> > > Is the applet being run off of a server (ie. a http URL)?  If the
> applet
> > > were running from the user's local disk through a file:// URL then the
> > > security restriction of being able to connect only back to the server
> that
> > > sent the .class files does not apply.
> > As long as we're using "appletviewer", it doesn't matter...
> > But this doesn't seem to hold true when using a browser(i used
> > netscape).
> I am almost certainly sure that when you open a page using the file:// URL
> (ie. a page local to your hard disk) and when this page contains an applet
> which is also local to your hard disk the "connect back only to server
> sending this applet" does not apply.

I'm afraid this is not true. Browser security exceptions are thrown in
both cases... the URL being file:// or being http:// doesnt make a

------------------------8<---------cut here--------8<-----------------
import java.awt.*;
import java.net.*;
import java.io.*;

public class Socklet extends java.applet.Applet {
String serverName;
int portNumber;

        public void init() {
        public void paint(Graphics g) {
        for(;;) {
                try {
                Socket socket=new Socket(serverName,portNumber);

                PrintWriter writer=new PrintWriter(new

                BufferedReader reader=new BufferedReader(new

                g.drawString("SERVER SAYS:" + reader.readLine(), 10,10);
                } catch (Exception e) {g.drawString("Error!" + e

------------------------>8---------cut here-------->8----------

HTML file to test: <Change the ServerName parameter to test>

    Test Socklet
 <body bgcolor="white">
   <applet code="Socklet.class" height=100 width=600>
   <param name="ServerName" value="">
   <param name="portNumber" value="25">

There is a natural hootchy-kootchy to a goldfish.
		-- Walt Disney
       R o h i t   R o m e h a r s h a n   S i n g h
     WORK:rohitsingh@xxxxxxxxxxxxxxx PLAY:rohit@xxxxxxxx