27.04.2013 Views

330 Java Tips.pdf - FTP Server

330 Java Tips.pdf - FTP Server

330 Java Tips.pdf - FTP Server

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Applets<br />

Receive our newsletter with new tips! Almost 6,000 subscribers (by June 2001) can not be wrong!<br />

They read our tips every week! To subscribe to The <strong>Java</strong> FAQ Daily send empty e-mail to:<br />

javafaq-tips-subscribe@topica.com or visit at:<br />

http://www.topica.com/lists/javafaq-tips/<br />

Applets<br />

I've got problems with the Socket class (network)<br />

I've got problems with the Socket class. I use it inside an applet (I've<br />

written a small chatbox). I have code like this:<br />

Socket s = new Socket("192.168.0.4", 13780);<br />

When the server I'm connecting to is on the same machine as the client, it works.<br />

When the server is an other machine, both NS and IE give an error message like:<br />

Security:Can't connect to 192.168.0.4 with origin ''<br />

Does anyone know how I can fix this??<br />

Answer: The standard security concept for an applet is the 'sandbox'. An applet can't talk<br />

outside it's memory space, can't talk to any files at all, and cannot talk to<br />

anything on the internet except the same machine that it's 'parent'<br />

HTML page originated from. So your applet can never talk to 192.168.0.4<br />

unless the HTML came from 192.168.0.4<br />

How do I view the error output from my <strong>Java</strong> applets in IE?<br />

Answer: The file windows\<strong>Java</strong>\<strong>Java</strong>log.txt contains info about the last Applet loaded in IE.<br />

All the System.out messages and exception information is stored here when <strong>Java</strong> Logging<br />

is enabled in IE. To enable <strong>Java</strong> Logging start IE and select View/Options/Advanced.<br />

Select "Enable <strong>Java</strong> Logging" check box click OK. Restart IE.<br />

In NT4 the file in C:\WINNT\<strong>Java</strong><br />

Is there a way to reduce the amount of time that it takes to download an applet?<br />

Answer: There is a way to reduce the amount of time an applet takes to download. What ever classes<br />

file:///F|/350_t/350_tips/applets.htm (1 of 10) [2002-02-27 21:17:49]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!