*
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
JavaRanch » Java Forums » Java » Applets
Bookmark "File Uploading Applet" Watch "File Uploading Applet" New topic
Author

File Uploading Applet

bharadwaja kambhammettu
Greenhorn

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" java.security.AccessControlException: access denied (java.util.PropertyPermission user.dir 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.checkPropertyAccess(Unknown Source)
at java.lang.System.getProperty(Unknown Source)
at java.io.Win32FileSystem.getUserPath(Unknown Source)
at java.io.Win32FileSystem.resolve(Unknown Source)
at java.io.File.getAbsolutePath(Unknown Source)
at sun.awt.shell.Win32ShellFolder2.<init>(Unknown Source)
at sun.awt.shell.Win32ShellFolder2.listFiles(Unknown Source)
at sun.awt.shell.ShellFolder.listFiles(Unknown Source)
at sun.awt.shell.Win32ShellFolderManager2.get(Unknown Source)
at sun.awt.shell.ShellFolder.get(Unknown 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(FileUploadApplet.java:105)
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 java.awt.EventDispatchThread.run(Unknown 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 java.io.FilePermission "<<ALLFILES>>","read";
permission java.net.SocketPermission "*","accept,connect,listen,resolve";
permission java.util.PropertyPermission "*","read";
permission java.security.AllPermission;
permission java.lang.RuntimePermission "readFileDescriptor";
};


plz clarify my doubts. Thanks in advance.


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

Joined: Mar 22, 2005
Posts: 41101
    
  45
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 ]

Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File Uploading Applet
 
Similar Threads
file reading in applet
put an applet into a web page
Exception Occurred when I added policy file
print Screen from a jsp
create a singed applet