wood burning stoves 2.0*
The moose likes Applets and the fly likes Applet doesn't work in browser. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Applet doesn Watch "Applet doesn New topic
Author

Applet doesn't work in browser.

Tristan Van Poucke
Ranch Hand

Joined: Jun 30, 2008
Posts: 47
I have written an Upload applet using commons.fileUpload library.
When I test the applet in Netbeans applet viewer the applet works and uploads the files. However when I test the applet in a browser , the applet loads but the Upload button doesn't work. No error or nothing it just doesnt work.


the method that is called when you click the Upload button.


[ UD: added linebreak to preserve layout ]
[ July 08, 2008: Message edited by: Ulf Dittmer ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41029
    
  43
Have you made sure that this method is in fact called? If it is, which lines of code are executed?

Are there any error messages in the Java Console?

How are you referencing the required jar files in your applet tag?
[ July 08, 2008: Message edited by: Ulf Dittmer ]

Ping & DNS - my free Android networking tools app
Tristan Van Poucke
Ranch Hand

Joined: Jun 30, 2008
Posts: 47
If I test the applet in the applet viewer the method is being run, not when i test the applet inside a browser.

This is how the applet is loaded.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41029
    
  43
So are there any error messages in the Java Console?
Tristan Van Poucke
Ranch Hand

Joined: Jun 30, 2008
Posts: 47
I cant open the java console since the applet is still running
[ July 08, 2008: Message edited by: Tristan Van Poucke ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41029
    
  43
That's unusual. Which OS are you running? In Windows in can be opened from the little Java icon at the lower right of the screen, regardless of whether an applet is running or not. It may need to be turned on first in the Java Plugin control panel.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Originally posted by Tristan Van Poucke:
I cant open the java console since the applet is still running


No idea what you mean there.

In any case, you do realize that browsers have security restrictions in place that prevent applets from doing potentially dangerous things like, for instance, accessing the local file system? Applets that need to do things like this need to be digitally signed, and then need to ask for permission to perform the action.


[Jess in Action][AskingGoodQuestions]
Tristan Van Poucke
Ranch Hand

Joined: Jun 30, 2008
Posts: 47
java.security.AccessControlException: access denied (java.io.FilePermission C:\Documents and Settings\josy\Mijn documenten\Adinda en weeskindjes al spelend.jpg read)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkRead(Unknown Source)
at java.io.File.isFile(Unknown Source)
at org.apache.commons.httpclient.methods.multipart.FilePartSource.<init>(FilePartSource.java:68)
at org.apache.commons.httpclient.methods.multipart.FilePart.<init>(FilePart.java:127)
at UploaderPack.Uploader$8.run(Uploader.java:285)
at java.security.AccessController.doPrivileged(Native Method)
at UploaderPack.Uploader.uploadPictures(Uploader.java:278)
at UploaderPack.Uploader$2$1.run(Uploader.java:110)
at java.security.AccessController.doPrivileged(Native Method)
at UploaderPack.Uploader$2.mouseClicked(Uploader.java:107)
at java.awt.AWTEventMulticaster.mouseClicked(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)


This is the error I get in java console. I figured it had something to do with security again and since I already signed my applet I tried to sign the commons jars also, didn't work though :s
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Applet doesn't work in browser.
 
Similar Threads
HttpClient file upload code review
Implementing file upload like CURL
upload file through applet
File Permission Error
How to upload a file from applet to the webserver ?