Tutorial :How to load java applet from django template



Question:

My applet runs file when I call it from a static applet.html file, like this:

<applet archive="applet.jar" code="com.xxx.yyy.PApplet"       width="100" height="20"></applet>  

But how do I put the same line in a django template? And where should I put the .jar and .java files? I also noticed that it appends .class to the PApplet while looking for the file and sends me a 404 error.

I tried googling and looked into documentation, but couldn't find this issue addressed anywhere before. Thanks for your help.


Solution:1

You should use your jar file as a static media file like an image ou CSS file via MEDIA_URL.

Put applet.jar in the media directory, then use

<applet archive="{{ MEDIA_URL }}applet.jar" code="com.xxx.yyy.PApplet"   width="100" height="20"></applet>  


Solution:2

This has nothing whatsoever to do with Django.

A Java applet for client-side use needs to be served in exactly the same way as any other static assets - CSS, Javascript, etc. So you'd put it wherever those files are, configure Apache or whatever to serve from there, and reference that directory in your applet tag.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »