By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,024 Members | 1,945 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,024 IT Pros & Developers. It's quick & easy.

How Can I Display an Image from Another Site?

P: n/a
Hi,
This works:

banner = getImage(GetCodeBase(),"mypicture.jpg")
But, I tried variations of:

try {
url = new URL("http://www.my-other-website.com/mypicture.jpg");
} catch (Exception e){}

banner = getImage(url);

And couldn't get that to work.
Can someone tell me how to display an image from a website other than the
one the applet is on?
Thanks very much,
- Jeff
www.bikewebsite.com

Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Wed, 29 Sep 2004 03:23:52 +0000, Jeff Napier wrote:
This works:
banner = getImage(GetCodeBase(),"mypicture.jpg")
But, I tried variations of:

try {
url = new URL("http://www.my-other-website.com/mypicture.jpg");
} catch (Exception e){}

banner = getImage(url);

And couldn't get that to work.
Can someone tell me how to display an image from a website other than the
one the applet is on?


I could be wrong, but I thought the default security policy for Java
prevented an applet from accessing data other than from the site the
applet was delivered from. In that case, you'de need to look at how to
alter the security policy (if it can be done for an applet).

Tony
Jul 17 '05 #2

P: n/a
Jeff Napier wrote:
Can someone tell me how to display an image from a website other than the
one the applet is on?


You basically have three options:

1) Sign your applet so it get more privileges.
You need an expensive certificate to do that and your users will have to
confirm a dialog box.

2) Make a little gateway on your server. This can be done with two lines
of PHP code. Give the URL of the foreign image as an parameter to your
script en let the script fetch and output the image.

3) Use Dynamic HTML (you can call JavaScript form within your applet
with LiveConnect [netscape.javascript.JSObject]).

Edwin Martin.

--
http://www.bitstorm.org/
Jul 17 '05 #3

P: n/a
Edwin Martin wrote:
Jeff Napier wrote:
Can someone tell me how to display an image from a website other than the
one the applet is on?

You basically have three options:

1) Sign your applet so it get more privileges.
You need an expensive certificate to do that and your users will have to
confirm a dialog box.


This is a popular misconception. You can create your own certificates
for free using the tools from Sun. The difference is that user will see
that you issued yourself your own certificate and it did not come from a
third party.

HTH,
Ray

--
XML is the programmer's duct tape.
Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.