applet cannot readfile on its server :(

C

charly

Greetings,

I got the following pb :

I got an applet who is given a param tag in the html file.
The param is the name of an xml file the applet is supposed to read.

the file is of course, on the server.

in my applet, I do new File(getparameter(blah)); and the usual stuff.

he does not find the file -> I tried to append
"http://localhost/appletdir/" + getparameter

I get AccessControlException: access denied java.util.PropertyPermission
user.dir read)

Now, the strangest thing :

I develop under eclipse. If I run the applet as an applet and specifies
the namefile in the parameters, it works "as is"

Any ideas ??
 
C

Christophe Vanfleteren

charly said:
Greetings,

I got the following pb :

I got an applet who is given a param tag in the html file.
The param is the name of an xml file the applet is supposed to read.

the file is of course, on the server.

in my applet, I do new File(getparameter(blah)); and the usual stuff.

he does not find the file -> I tried to append
"http://localhost/appletdir/" + getparameter

I get AccessControlException: access denied java.util.PropertyPermission
user.dir read)

Now, the strangest thing :

I develop under eclipse. If I run the applet as an applet and specifies
the namefile in the parameters, it works "as is"

Any ideas ??

That is completely normal: a File object operates on the *local* filesystem.
When you run the applet on a client, it can not use a File object to get a
file on the server.

Anyway, as to your specific problem, can't you use an URL instead of a File
to read the XML file?
 
C

charly

That is completely normal: a File object operates on the *local*
filesystem.
When you run the applet on a client, it can not use a File object to get a
file on the server.

Anyway, as to your specific problem, can't you use an URL instead of a File
to read the XML file?

I wish I could :)

Could you give me some pointers regarding reading from an url please ?

I'm not used to working with urls :(

thx a bunch !
 
C

charly

Probably you're reading the xml file using an InputStream you created from
the file, right?

You can also get an InputStream from the URL:
http://java.sun.com/j2se/1.4.2/docs/api/java/net/URL.html
look for the openStream() method.
No actually, I did it like this :
File file = new File(nomFich);
// Parse the file

DocumentBuilder builder =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = builder.parse(file);

I'm not that used with streams :(

Now, I'm trying this :
DocumentBuilder builder =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
//Document doc = builder.parse(file);

Document doc = builder.parse("http://localhost/applets/donnees.xml");

But It seems I'm gonna need an intermediate stream :(
 
C

charly

Okay, I managed with streams, now, the web server is driving me nuts !!

I'm trying to genrate graphics stats with jfreechart-0.9.18

my html code :
<HTML>
<HEAD>
<TITLE>Hello to Everyone!</TITLE>
</HEAD>
<BODY>
<APPLET codebase="http://localhost/applets/classes"
CODE="AppletBarChartDemo.class"
WIDTH="400"
HEIGHT="325"
archive="jfreechart-0.9.18.jar, jcommon-0.9.3.jar, log4j-1.2.8.jar>
<PARAM name="sourcexml" value="donnees.xml" >
</APPLET>
</BODY>
</HTML>

as you can see, nothing revolutionary :(

My console says :

java.io.IOException: Server returned HTTP response code: 400 for URL:
http://localhost/applets/classes/log4j-1.2.8.jar>
java.lang.NoClassDefFoundError: org/apache/log4j/Logger

java.lang.NoClassDefFoundError at
org.jfree.chart.ChartFactory.createBarChart(ChartFactory.java:386)


java.lang.NoClassDefFoundError at
org.jfree.chart.ChartFactory.createBarChart(ChartFactory.java:386)

but my webserver is thus :
root/applets/classes/
in it, I got the class files and the afore mentioned jars

And of course, I can still run it under eclipse as an applet !!!

Browser is IE6 and Firefox

any tips ?
 

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,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top