Cannot load image in applet after placing it in a package

G

Gerrit Hulleman

This has been a much discussed topic in several newsgroups, but I still
cannot figure it out.

I got this class: htmledit.class. Normal website linking to this class as an
applet. Several image files (gif&bmp) for toolbar images.

/
| -htmledit.class
|
|-image1.gif
\-image2.gif

Applet loads, no problem. images are used in the toolbar. Applet tag calls
"htmledit.class"

Trying to get the class in a package (due to OO reasons and java 1.4 jdk) I
get:
/
|-/main
| \-htmledit.class
|
|-image1.gif
\-image2.gif

Changed the header of the htmledit.class to main package, changed the html
code to call the class "main.htmledit.class". Applet loads, get null values
from getResource() call. No images are loaded.

This applet is not (yet) part of a jar file. Tried copying the image files
to the main directory, add codebase, place them in a jar with archieve
attribute in the applet tag, calling image file with a "/" in front of it.

Why is the main applet class no longer able to access the image files when
placed in a package?


G
 
A

Andrew Thompson

This has been a much discussed topic in several newsgroups, but I still
cannot figure it out.

Can you figure it out in an aplication?

Do that first.
 
G

Gerrit Hulleman

Had tried an app. That works The strange thing is that the problem only
occures when trying to load the applet using a webserver.

A java application is able to get the image using the '/' prefix. The sun
applet viewer is able to load the images using the same prefix. Using a
browser to the htm file
(file://localhost/D:/System/eclipse/workspace/htmledit2_test/Htmledit.htm),
images are loaded. (IE & Opera).

But when the browser loads the applet via the IIS server
(http://localhost/Htmledit.htm) (set to the same dir as the direct link),
images are left out.

This only happens if the Htmledit class is in a package. Otherwise images
are loaded. That is why I think about applet security. But I cannot get my
finger on it. Any suggestions?
 
A

Andrew Thompson

Any suggestions?

Do not top-post, is one.
...
Had tried an app. That works The strange thing is that the problem only
occures when trying to load the applet using a webserver.

What web-server? Put the applet up and
give us the URL..

This might be fixed by 'jar'ing your
package, but I cannot see how that will
help if the image is external, but I
am sure you can find resources in this
situation..

What is the 'codebase' attribute.. no,
stuff that, give us the URL.
 
G

Gerrit Hulleman

Just figured it out... it is the localhost.. ( ox )

Applets are allowed to contact the server they are loaded from. The server
is set on IP, the applet is not allowed to contact the localhost. ( >< )

Used the links http://127.0.0.1/Htmledit.htm and
http://192.168.255.136/Htmledit.htm (local network IP), and the images are
loaded.

Just posting a possible solutions for other developers (searching newsgroups
via a searchengine).
 
R

Roedy Green

"Applet Restrictions" - point..

FROM
"look at the restricted system properties. "

TO
"look at the restricted system properties or
get an enumeration of the properties. "

done.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top