adding Java applet - codebase reference?

adding Java applet - codebase reference?

by Lael ... -
Number of replies: 11
Hi!

I am trying to add a Java apple to an assignment / html resource... (trusted content... - so tags are not being stripped)

It works fine if I try to reference the CODEBASE (folder reference where the class is contained) to another directory on a server - what I want to do is to upload the class file to the course and then reference it from there.

Any ideas? (from looking around at the forums it seems like others have done this... so... just need a pointer for the right location...)

Thanks!

Lael
Average of ratings: -
In reply to Lael ...

Re: adding Java applet - codebase reference?

by Lael ... -
Hi,

bumping this one...
strikes me that this should not be hard - but I can't seem to figure it out. If anyone knows/ believes it is not possible? - can you reply and let me know? thanks.

I have tried referencing it like an image is referenced - with no success.

(eg: codebase="http://server/moodle/file.php?file=/6/classesinhere")

Thanks!

Lael
In reply to Lael ...

Re: adding Java applet - codebase reference?

by John Isner -
Sorry you were ignored. I think the original question was a bit confusing. Maybe that's why.

If the original codebase is an absolute URL and you want to move the contents of the URL into your Moodle install, then you need to replace the absolute URL by a relative one. The relative URL should be relative to the directory containing the page with the applet tag.

Example: Suppose that the original codebase says


In the directory with your page (the one containing the applet tag), create a subdirectory "applet", and below that another subdirectory "classes". Then copy everything in http://foo.com/applet/classes to your new classes directory. Finally, change the codebase to

./applet/classes/

Even though it is not necessary to create the subdirectories, I do it this way because I want my structure to mirror the structure of the original site (the dot becomes a stand-in for "http://foo.com")

Does that answer your question?
In reply to John Isner

Re: adding Java applet - codebase reference?

by Lael ... -
Sorry for the delayed response. I tried your suggestion, but still am unable to get it to work.

I have a course in moodle, and in the course files for that course I have a folder called 'classes'. The codebase is inside that folder.

Is there a way to reference folders and files inside the files section by using a relative reference within moodle? eg: from a label, from a web page etc that is created from within moodle?

was the suggestion above the way to do it? (I understand that in a normal website it would work, is it different b/c of moodle using php?)

thankyou for your help!

In reply to Lael ...

Re: adding Java applet - codebase reference?

by Rod Ward -

If it doesn't work, it has nothing to do with PHP, but would probably have to do with the fact that the moodledata folder (where the course files live) is not usually inside the web server. It's usually outside and might even be on another drive (depending on your implementation).

It's recommended that the moodledata folder sits outside the htdocs or inetpub/wwwroot folders to keep the course files secured against attack or unauthorised browsing. Moodle uses file.php to fetch course files from moodledata and serve them up as if they came from the normal web folders area, but in fact they are not.

So your relative links may not work as expected for this reason.

Average of ratings: Useful (1)
In reply to Rod Ward

Re: adding Java applet - codebase reference?

by Lael ... -
Thanks Rod,

moodledata is definitely on a different drive. The question that I am left asking...

are relative links possible at all from within a moodle course?

What does moodle do about links when restoring a course? I recently restored a course after updating the system to 1.8.2 and found that the links I had created to a network drive (\\server\folder\folder) were restored fine...

but I had also uploaded some portable apps to be used within the course into the course files area- accessed from a link in an html block... these links were NOT restored.

Does this also happen to links to the course files area from within resources etc? (moodle activities)

The other links that broke were also absolute - I was using .swf files in a glossary as a repository of software tutorials/ how-tos... and then directing students to find them there... (they were in course files area in subfolder called tutorials - and then linked to with the media filter on)...

SO....

Anyone know how to do relative links to course files??? (or can moodle be updated to automatically restore these links? - not fun to have to recreate every single one!)

Lael
In reply to Lael ...

Re: adding Java applet - codebase reference?

by John Isner -
Very interesting. I checked all of my applets. None of my codebases is in $CFG->dataroot. They're all either pointing to external sites or to directories under $CFG->dirroot. So my applets are not being accessed by file.php.

I see that you tried

codebase="http://server/moodle/file.php?file=/6/classesinhere"

which is what I would have suggested.

IN FACT ... I just did a search on the main page of moodle.org )using the search terms "applet codebase") and came across this post where I asked the same question nine months ago. Here's a similar discussion. I don't see any discussion that has a definitive answer. You may just have to put codebase in a publicly accessible place.

If you find a solution, please post it.
In reply to John Isner

Re: adding Java applet - codebase reference?

by Lael ... -

smile makes me feel better about not finding a solution so far...

but wishing I could find a real solution to this  - not so far.

Lael

In reply to Lael ...

Re: adding Java applet - codebase reference?

by John Isner -
Well, I am sorry to make you feel worse, but yesterday I checked some of my applets and I did find a few that are working the way I originally suggested. That is, the applet code (jar and class files) is in course files and the applet tag has a codebase parameter containing file.php. Here is an example applet tag:

<applet name="GraphPAD_1"
codebase="http://192.168.1.104/training/file.php/10"  archive="GraphPAD_1.jar"  code="diagrammer.PAD.GraphPAD.class"
align="top"  height="190"  hspace="0"
vspace="0"  width="260"> 


In reply to John Isner

Re: adding Java applet - codebase reference?

by Lael ... -
:D Awesome! thanks for making the effort

ok - so it SHOULD be possible then... (not as a relative reference... but as an absolute...) hmm - ok, work for me to do.
In reply to John Isner

Re: adding Java applet - codebase reference?

by Rod Ward -

John and Lael,

After watching this thread for a while I've noticed that you have either slightly different settings in slash arguments or else are on different web servers or both.

According to your posts, John's links look like this:

codebase="http://192.168.1.104/training/file.php/10"  (I'm assuming here that John has named his moodle folder "training" instead of "moodle")

...and Lael's look like this:

codebase=http://server/moodle/file.php?file=/6/classesinhere  (Lael is using "moodle" as his moodle folder)

These links tell a story. John's has file.php followed by slash arguments like this: file.php/n but Lael's has file.php?file=/n

So it looks to me like John is on Apache server with slash args ON. Am I right? And Lael is either on Apache server...or IIS server... but with slash args OFF.  If Lael has already tried turning on slash arguments and things still didn't work, I'm guessing it's IIS server. Am I right?

Now for Moodle users running Apache server, this issue with the way Moodle uses file.php to fetch files from moodledata, and the way it causes linked files not to be found, is usually easily solved by toggling the slash arguments setting under Admin > Server > Http > Use Slash Arguments. If Moodle images don't work out of the box, wth Apache you change this setting, and it's normally fixed.

However, for IIS the fix is not as simple because IIS doesn't let you use slash arguments. So a URL like http://192.168.1.104/training/file.php/10 will work fine in Apache but return a 404 error in IIS...whatever setting you use for slash arguments.

For anyone on IIS intending to get relative links to work, reading this forum thread may help: http://moodle.org/mod/forum/discuss.php?d=80548

Does this provide any help?

In reply to Rod Ward

Re: adding Java applet - codebase reference?

by Rod Ward -

I just Googled GoDaddy to find out if they were using IIS as web server. The links in Google to pages on their site are ASP pages, which makes me believe it is almost certain they are running IIS.

So I'm now even more sure that your issues are due to IIS and its inability to handle slashed arguments.