aspose file tools*
The moose likes Applets and the fly likes how to execute applet through webserver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "how to execute applet through webserver" Watch "how to execute applet through webserver" New topic
Author

how to execute applet through webserver

feroz pasha
Greenhorn

Joined: Aug 22, 2008
Posts: 13
this is the exception i amgetting sir pl help me


Java Plug-in 1.5.0_12
Using JRE version 1.5.0_12 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\Emminent


----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
p: reload proxy configuration
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------

load: class java.Backup not found.
java.lang.ClassNotFoundException: java.Backup
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed.
at sun.applet.AppletClassLoader.getBytes(Unknown Source)
at sun.applet.AppletClassLoader.access$100(Unknown Source)
at sun.applet.AppletClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 10 more

i am getting this one

and my applet tag in html is in this way

<Applet code="java.Backup" Width=920 height=580 >
<PARAM NAME="questionDir" VALUE="/AllQuestions">
</Applet>

and my directory structure is

appletcode ( App.html)/WEB-INF/classes/java(applet class file ,AllQuestion folder)

this online exam project where i am reading the questions from folder AllQuestions and display it in applet when i click the button this folder is in java as shown in above directory structure

pl pl
pl
help me

thanks in advance
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41800
    
  62
Nothing that's inside of the WEB-INF directory will be served to a browser. You'll need to move all files related to the applet into a publicly accessible directory (like the one where the HTML file resides in). That includes class files, jar files (if any) and data files (like questionDir).


Ping & DNS - my free Android networking tools app
feroz pasha
Greenhorn

Joined: Aug 22, 2008
Posts: 13
i did in that way also but it was showing the java.io.filepermission and AccessControlException


wat sall i do for this can you help me pl pl
Ananth Chellathurai
Ranch Hand

Joined: Nov 21, 2007
Posts: 349

Dear Pasha,

You need to go through some basics of Applets. Please visit FAQ session to have some basic ideas of Applet.

Ananth Chellathurai


Ananth Chellathurai [Walk on software]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41800
    
  62
Whenever you mention that you're getting exceptions you should post the full stack trace. There's additional information in the exception message that helps diagnose the problem. Without that, people here can only guess what's going on.
feroz pasha
Greenhorn

Joined: Aug 22, 2008
Posts: 13
Java Plug-in 1.5.0_12
Using JRE version 1.5.0_12 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\Emminent


----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
p: reload proxy configuration
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------

The Direcory location=null
Full directory path=/localhost:7001/appletcodenull
java.security.AccessControlException: access denied (java.io.FilePermission \localhost:7001\appletcodenull 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.isDirectory(Unknown Source)
at Backup.init(Backup.java:131)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


this is the exception i am getting sir
help me what is the next step shall i take to over come the exception
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41800
    
  62
The fact that the file path contains the string "null" should be a clear indication of what is going wrong.

Aside from that, applets are not allowed to perform file I/O without being signed, or unless the local security policy has been altered. It looks as if neither is the case. See HowCanAnAppletReadFilesOnTheLocalFileSystem for more detail.
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 686
It looks like your code is executing but:
at java.io.File.isDirectory(Unknown Source)
at Backup.init(Backup.java:131)

Is your applet at source line 131 trying to look at the local file system?
Applet's can't do that without permission.
Ananth Chellathurai
Ranch Hand

Joined: Nov 21, 2007
Posts: 349

Applets can look only for files from the server from where it is served from.

Ananth Chellathurai
feroz pasha
Greenhorn

Joined: Aug 22, 2008
Posts: 13
i have set the access permission buy
keytool -genkey -keyalg rsa -alias feroz
after i made the certificate:

keytool -export -alias feroz -file yourcert.crt

after that i have created a bat file which contains

javac Backup.java
jar cvf Backup.jar Backup.class
jarsigner Backup.jar feroz


The batch-file compiles the applet, makes a jar-archive and signs the jar-file.

but when i am running my html file iam getting this exception.

Java Plug-in 1.5.0_12
Using JRE version 1.5.0_12 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\emminent


----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
p: reload proxy configuration
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------

file:/C:/AppletCode/AllQuestions/Question1.java
java.lang.SecurityException: class "Backup$1"'s signer information does not match signer information of other classes in the same package
at java.lang.ClassLoader.checkCerts(Unknown Source)
at java.lang.ClassLoader.preDefineClass(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at Backup.init(Backup.java:154)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
what should i do
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to execute applet through webserver