File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Applets and the fly likes How to load an image in applet from web server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "How to load an image in applet from web server" Watch "How to load an image in applet from web server" New topic
Author

How to load an image in applet from web server

Srikanth Reddy
Greenhorn

Joined: Jun 05, 2004
Posts: 10
I have an applet loaded by a servlet from my main web server. This applet has to load an image from my another web server. I know that applet loaded by one web server cannot access resources from other web servers. And I cannot put signed applet signed by a certificating authority. What way can I load the image ? Thanks in advance.


Srikanth<br />SCJP 1.4
sachin pathak
Greenhorn

Joined: Jun 05, 2002
Posts: 27
Hi there
Hope follwing code inside the class implementing applet helps.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8707
    
    6

You can use a server application, like a servlet, on your main web server to act as a proxy. Your applet contacts the main web server, the main web server downloads the image and returns it with the applet's request. Your applet never leaves the sandbox so its happy. The server is an application so it can do whatever it wants.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Paul Houser
Ranch Hand

Joined: Nov 06, 2003
Posts: 34
This is what I do to load an image:

Image image = this.getImage(getDocumentBase(), "images/image.png");

where: "this" is the class implementing the applet (presuming you load the image from that class) and getDocumentBase() returns the folder of html file running the applet


Hope that helps.


Paul Houser<br />paulygon.org<br />"Just say NO to emoticons"
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to load an image in applet from web server
 
Similar Threads
Inconsistent FileNotFoundException
Signed Applets unable to gain port access on client
using java.awt.robot with Applet
getImage Problem
uncatchable exceptions when loading images