This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Applets and the fly likes File Uploading Applet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "File Uploading Applet" Watch "File Uploading Applet" New topic

File Uploading Applet

bharadwaja kambhammettu

Joined: Apr 07, 2005
Posts: 5
hi all,

I am trying to write a JApplet, which will let me select a directory on the clients machine enabling me to upload all the files in that dir and send them to a servlet.

I tried signing the applet using the "keytool" (actually followed some article from the Sun`s site), attempted to create a Policy file and finally used the "HTMLConverter" to convert the applet.

But the Sun Java Console in Internet Explorer shows a big exception stack trace. It goes like this -- >

Exception in thread "AWT-EventQueue-11" access denied (java.util.PropertyPermission user.dir read)
at Source)
at Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
at java.lang.System.getProperty(Unknown Source)
at Source)
at Source)
at Source)
at<init>(Unknown Source)
at Source)
at Source)
at Source)
at Source)
at javax.swing.plaf.metal.MetalFileChooserUI.updateUseShellFolder(Unknown Source)
at javax.swing.plaf.metal.MetalFileChooserUI.installComponents(Unknown Source)
at javax.swing.plaf.basic.BasicFileChooserUI.installUI(Unknown Source)
at javax.swing.plaf.metal.MetalFileChooserUI.installUI(Unknown Source)
at javax.swing.JComponent.setUI(Unknown Source)
at javax.swing.JFileChooser.updateUI(Unknown Source)
at javax.swing.JFileChooser.setup(Unknown Source)
at javax.swing.JFileChooser.<init>(Unknown Source)
at javax.swing.JFileChooser.<init>(Unknown Source)
at FileUploadApplet.actionPerformed(
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(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.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at Source)

I actually could`nt figure out certain things right.
-- > Does the policy file created have any relevance to the Browser`s JRE ?(i`ve Java Plug-in 1.5.0_03
Using JRE version 1.5.0_03 Java HotSpot(TM) Client VM)

--> "HTMLConverter" converts the original html containing the <APPLET> into a way that the Java Plug-in for the browser understands. Is this right ?

Incidentally, the applet did`nt run even i used "appletviewer" and it showed the same exception trace.

my policy file goes like this -->

grant codebase "http://localhost:7001/FileUploadApp/~"
permission "<<ALLFILES>>","read";
permission "*","accept,connect,listen,resolve";
permission java.util.PropertyPermission "*","read";
permission java.lang.RuntimePermission "readFileDescriptor";

plz clarify my doubts. Thanks in advance.

cheers & take care,<br />Bharadwaja K
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
A couple of points in no particular order:

- If you sign the applet, there should be no need to change the policy file, and vice versa - they both allow the applet to run with fewer or without any security restrictions.

- Policy file syntax hasn't changed since its inception, so the JVM version you create it with, and the version you run it with, should make no difference.

- Is there a way you can verify whether the policy file is being found and used by the JVM? Maybe it's in the wrong directory.

- Yes, HTMLConverter spits out HTML that uses the EMBED or OBJECT tags. Have a look at this page to see how such a tag compares to the APPLET tag (at the end of the page).
[ December 21, 2005: Message edited by: Ulf Dittmer ]
I agree. Here's the link:
subject: File Uploading Applet
It's not a secret anymore!