From JavasSript called signed (FileDialog) Applet Problems...

Hallo,
I want to read a by JavaScript opened selected file with the FileDialog in a Byte[], and give this Byte[] back to JavaScript. I have this code for my unsigned applet working fine without reading the selected file in a byte[], but give the filepath and name back to JavaScript:
import java.applet.Applet;
import java.awt.FileDialog;
import java.awt.Frame;
import netscape.javascript.JSObject;
public class OpenFileDialogJava6 extends Applet
     private static final long serialVersionUID = -1401553529888391702L;
     private Frame m_parent;
    private FileDialog m_fileDialog;
*Displays a file dialog, calling standard JavaScript methods when the*
user selects a file or cancels the dialog.
*    public void newFileDialog(String onFileJS, String onCancelJS)*
*          System.out.println("open Dialog...");*
*         openDialog(onFileJS, onCancelJS);*
*Displays a file dialog, calling the specified JavaScript functions when*
the user selects a file or cancels the dialog.
@param onFile The name of the function to call when the user selects a
*file.*
@param onCancel The name of the function to call when the user cancels
*a dialog selection.*
    public void openDialog(final String onFile, final String onCancel)
         System.out.println("Calling open dialog...");
         if (m_parent == null)
             m_parent = new Frame();
        if (m_fileDialog == null)
             m_fileDialog = new FileDialog(m_parent, "Medien hinzufügen", FileDialog.LOAD);             
        m_fileDialog.setVisible(true);       
        m_fileDialog.toFront();
        final String directory = m_fileDialog.getDirectory();  
        final String returnFile = m_fileDialog.getFile();
         m_fileDialog.setVisible(false);     
        m_parent.setVisible(false);
        if (returnFile == null)
             System.out.println("onCancel");
             callJavaScript(onCancel);     
        else
             System.out.println("onFile");
             System.out.println(directory+returnFile);
             callJavaScript(onFile, directory+returnFile);
     private void callJavaScript(final String func, final Object... args)
          final JSObject window = JSObject.getWindow(OpenFileDialogJava6.this);
          if (window == null)
              System.out.println("Could not get window from JSObject!!!");
              return;
          System.out.println("Calling func through window");
          try
               window.call(func, args);
          catch (final Exception e)
              System.out.println("Got error!!"+e.getMessage());
              e.printStackTrace();
              showError(e);
          System.out.println("Finished JavaScript call...");
     private void showError(final Exception e)
          final String[] args = new String[]{e.getMessage()};
          final JSObject window = JSObject.getWindow(this);
          try
               window.call("alert", args);
          catch (final Exception ex)
               System.out.println("Error showing error! "+ex);
}I self-sign the Jar and write that byte[] test = (byte[]) java.security.AccessController.doPrivileged(
          new java.security.PrivilegedAction() to the code in where I want to read the file.....
So now I started to change the code in the public void openDialog(final String onFile, final String onCancel) to get the Byte[] of the selected File
        final String directory = m_fileDialog.getDirectory();  
        final String returnFile = m_fileDialog.getFile();
        final File file = new File(directory+
                File.separator +returnFile);
        byte[] test = (byte[]) java.security.AccessController.doPrivileged(
          new java.security.PrivilegedAction()
               public Object run()
                  try
                      FileInputStream fileInputStream = new FileInputStream(file);
                      byte[] data = new byte[(int) file.length()];
                      try
                           fileInputStream.read(data);
                           fileInputStream.close();
                           return data;
                      catch(IOException iox)
                            System.out.println("File read error...");
                            iox.printStackTrace();
                            return null;
                 catch (FileNotFoundException fnf)
                       System.out.println("File not found...");
                       fnf.printStackTrace();
                       return null;
         m_fileDialog.setVisible(false);     
        m_parent.setVisible(false);
.......Without signing the jar: I get this in IE 8:
Meldung: java.security.AccessControlException: access denied ("java.io.FilePermission" "C:\xampp\htdocs\index.php" "read")
Zeile: 6
Zeichen: 1
Code: 0
URI: file:///E:/FH%20Kempten/Semester%206/Java/Java%20Projekte/OpenFileDialogJava6/bin/Neues%20Textdokument.html
Ok this I understand, but when I sign it, I open my FileDialog, select a file, ok -> nothing happens: Firfox and IE show me:
uncaught exception: java.lang.reflect.InvocationTargetException*
And in Java Console nothing: Just my Output:
open Dialog...
Calling open dialog...

Hallo,
I want to read a by JavaScript opened selected file with the FileDialog in a Byte[], and give this Byte[] back to JavaScript. I have this code for my unsigned applet working fine without reading the selected file in a byte[], but give the filepath and name back to JavaScript:
import java.applet.Applet;
import java.awt.FileDialog;
import java.awt.Frame;
import netscape.javascript.JSObject;
public class OpenFileDialogJava6 extends Applet
     private static final long serialVersionUID = -1401553529888391702L;
     private Frame m_parent;
    private FileDialog m_fileDialog;
*Displays a file dialog, calling standard JavaScript methods when the*
user selects a file or cancels the dialog.
*    public void newFileDialog(String onFileJS, String onCancelJS)*
*          System.out.println("open Dialog...");*
*         openDialog(onFileJS, onCancelJS);*
*Displays a file dialog, calling the specified JavaScript functions when*
the user selects a file or cancels the dialog.
@param onFile The name of the function to call when the user selects a
*file.*
@param onCancel The name of the function to call when the user cancels
*a dialog selection.*
    public void openDialog(final String onFile, final String onCancel)
         System.out.println("Calling open dialog...");
         if (m_parent == null)
             m_parent = new Frame();
        if (m_fileDialog == null)
             m_fileDialog = new FileDialog(m_parent, "Medien hinzufügen", FileDialog.LOAD);             
        m_fileDialog.setVisible(true);       
        m_fileDialog.toFront();
        final String directory = m_fileDialog.getDirectory();  
        final String returnFile = m_fileDialog.getFile();
         m_fileDialog.setVisible(false);     
        m_parent.setVisible(false);
        if (returnFile == null)
             System.out.println("onCancel");
             callJavaScript(onCancel);     
        else
             System.out.println("onFile");
             System.out.println(directory+returnFile);
             callJavaScript(onFile, directory+returnFile);
     private void callJavaScript(final String func, final Object... args)
          final JSObject window = JSObject.getWindow(OpenFileDialogJava6.this);
          if (window == null)
              System.out.println("Could not get window from JSObject!!!");
              return;
          System.out.println("Calling func through window");
          try
               window.call(func, args);
          catch (final Exception e)
              System.out.println("Got error!!"+e.getMessage());
              e.printStackTrace();
              showError(e);
          System.out.println("Finished JavaScript call...");
     private void showError(final Exception e)
          final String[] args = new String[]{e.getMessage()};
          final JSObject window = JSObject.getWindow(this);
          try
               window.call("alert", args);
          catch (final Exception ex)
               System.out.println("Error showing error! "+ex);
}I self-sign the Jar and write that byte[] test = (byte[]) java.security.AccessController.doPrivileged(
          new java.security.PrivilegedAction() to the code in where I want to read the file.....
So now I started to change the code in the public void openDialog(final String onFile, final String onCancel) to get the Byte[] of the selected File
        final String directory = m_fileDialog.getDirectory();  
        final String returnFile = m_fileDialog.getFile();
        final File file = new File(directory+
                File.separator +returnFile);
        byte[] test = (byte[]) java.security.AccessController.doPrivileged(
          new java.security.PrivilegedAction()
               public Object run()
                  try
                      FileInputStream fileInputStream = new FileInputStream(file);
                      byte[] data = new byte[(int) file.length()];
                      try
                           fileInputStream.read(data);
                           fileInputStream.close();
                           return data;
                      catch(IOException iox)
                            System.out.println("File read error...");
                            iox.printStackTrace();
                            return null;
                 catch (FileNotFoundException fnf)
                       System.out.println("File not found...");
                       fnf.printStackTrace();
                       return null;
         m_fileDialog.setVisible(false);     
        m_parent.setVisible(false);
.......Without signing the jar: I get this in IE 8:
Meldung: java.security.AccessControlException: access denied ("java.io.FilePermission" "C:\xampp\htdocs\index.php" "read")
Zeile: 6
Zeichen: 1
Code: 0
URI: file:///E:/FH%20Kempten/Semester%206/Java/Java%20Projekte/OpenFileDialogJava6/bin/Neues%20Textdokument.html
Ok this I understand, but when I sign it, I open my FileDialog, select a file, ok -> nothing happens: Firfox and IE show me:
uncaught exception: java.lang.reflect.InvocationTargetException*
And in Java Console nothing: Just my Output:
open Dialog...
Calling open dialog...

Similar Messages

  • I am using a Application in c dll calling from jni jar by java applet in firefox version 19.0 , the problem is click event message box will not working correct

    I am using a Application in c dll calling from jni jar by java applet in firefox version 19.0 , the problem is button click event message box or popup window will not working correctly. Please any one suggest me the steps to overcome this not responding or slowness in the responding problem of Button click event.

    Hello,
    In Firefox 23, as part of an effort to simplify the Firefox options set and protect users from unintentially damaging their Firefox, the option to disable JavaScript was removed from the Firefox Options window.
    However, the option to disable JavaScript was not removed from Firefox entirely. You can still access it from about:config or by installing an add-on.
    '''about:config'''
    # In the address bar, type "about:config" (with no quotes), and press Enter.
    # Click "I'll be careful, I promise"
    # In the search bar, search for "javascript.enabled" (with no quotes).
    # Right click the result named "javascript.enabled" and click "Toggle". JavaScript is now disabled.
    To Re-enable JavaScript, repeat these steps.
    '''Add-ons'''
    You can alternatively install an add-on that lets you disable JavaScript, such as
    *[https://addons.mozilla.org/firefox/addon/noscript/ No-Script] (to disable JavaScript on a per page basis, as required)
    *[https://addons.mozilla.org/firefox/addon/quickjava/ QuickJava] (to easily disable and enable JavaScript, automatic loading of images, and other content)
    Thank you and I hope this helps!

  • Can i call signed applet from jsf page in sun studio creator

    Hello javites,
    I want to know whether i can call signed applet from jsf page in sun studio creator. If possible, how do i go about it.
    Thanks.

    This tutorial may help:
    http://developers.sun.com/prodtech/javatools/jscreator/reference/techart/2/applet.html?feed=DSC

  • Signed Applet problems in Vista + JMF

    Hi All,
    I'm new to Java Applet programming. I wrote an application which works as a VoIP Client in a webpage (Using JMF). Its working very fine in allmost all Windows XP machines.
    But not in Windows Vista machines. In Vista i'm getting the following error :
    "No permission to capture from applet" - Since its a Signed applet. The application is digitally signed from a CA. Even though its not working in Vista (IE and Mozilla Firefox also).
    I have went through the following link which says IE in Vista will run on protected mode, so Signed Applet will not have all the permission eventhough its signed for "AllPermission".
    ----- http://java.sun.com/javase/6/webnotes/install/system-configurations.html
    And also I'm not able to create a customized jar file for JMF using JMF Customizer. (JMF Customizer is an application which creates a jar file with specified classes). While creating a jar file I'm getting particular class is not available. (In Windows XP, this class is compilled at run time).
    Please let me know the following things,
    a) Is there any security settings i have to make to run Signed Applet in Windows Vista ?
    b) What is Java Policy file? I don't have any policy file - will it affect the application ?
    c) Do I need to sign each applet (say i have 5 applets in single jar file) ?
    d) In Vista how Mozilla Firefox are running (like IE7's restricted environment or XP compatiable mode) ?
    Thanks in Advance,
    Karthikeyan R

    I have exatly the same problem but not with the class itself. I have the problem with an jar that my class calls.
    I use jdk1.4.2. I think it's basicaly the same problem as "lfpgMW".
    I'll also whould like an idea...
    thanks

  • Signed Applet problems

    Hi all,
    I have a problem with one applet. I just built an applet (JDK 1.2) to download a file to the local machine; so far is OK, I got my digital certificate and I have signed the applet. Now when I test it in IE 5.x or 6.x it shows me the certificate and of course I trust, so it writes to the local hard drive, but when I try to test in Netscape 4.7 or greater; it shows me the certificate, I choose the "Trusted option" but I got the error:
    access denied (java.io.FilePermission c:\mwSave.dll write)
    I don't have any idea why if my applet is already signed and the certificate is valid I am getting this error... I am using a signed applet to do not use the policy file.... and should work, well I think that....
    Any ideas....
    Thanks in advance.

    I have exatly the same problem but not with the class itself. I have the problem with an jar that my class calls.
    I use jdk1.4.2. I think it's basicaly the same problem as "lfpgMW".
    I'll also whould like an idea...
    thanks

  • JavaScript calls method on Java Applet-- Problem

    Hi all,
    I have a problem as following:
    I have a method on JavaScript calling a method on Java Applet. A method on JavaScript repeatedly retrieves data form the server , let's say; every 100 ms and it calls the method on Java to draw a graph(I use thread to call repaint()). The problem is, if I leave the applet site(or the site has lost the focus), the stop() will be called and I can't recieve data from JavaScript anymore. If I go back to the site, the applet starts, but the graph doesn't show the figure, as it supposes to show.
    how can I tell the browser doesn't call the stop() or there is another way to solve this problem?
    Thanks for all answers. CU.
    A-Pex

    my own fault.. it's not the browser or the applet.. It's my computer.. it's too old for this applet..
    Does anyone know, how to optimize the applet with thread? thanks..

  • Signed Applet problem

    Hi all,
    I have a problem about disappering the "JApplet Window" Text.
    I am now writing a JApplet using swing technology. The JApplet want to access the local client harddisk so I need to sign the applet. There are serveral classes, one is extending JApplet and the other are extending JDialog. the JApplet class will show or hide the JDialog class.
    In the JDialog class, it will validate something and it will popup error dialog by using JOptionPane.showMessageDialog(). However, the problem occur, the popup dialog has a text "JApplet Window" at the bottom.
    I want to make the text disappear, Can you tell me the way to do that?
    thanks

    when you sign the applet, you are signing the Jar file, so any "dialogs" created from classes in the signed jar, shouldn't have that message on their windows. But then again, neither should popup menus in unsigned applets, but sometimes it does.

  • How can I display the HTML page from servlet which is called by an applet

    How can I display the HTML page from servlet which is called by an
    applet using the doPost method. If I print the response i can able to see the html document. How I can display it in the browser.
    I am calling my struts action class from the applet. I want to show the response in the same browser.
    Code samples will be appreciated.

    hi
    I got one way for this .
    call a javascript in showDocument() to submit the form

  • I have recently upgraded to iPhone 5 from 4, call line identity doesn't work when call other iPhones.  It works when calling any other brand of cell phone.  Network carrier assures me problem is not on there side.  Any assistance will be appreciated.

    I have recently upgraded to iPhone 5 from 4, call line identity doesn't work when call other iPhones.  It works when calling any other brand of cell phone.  Network carrier assures me problem is not on there side.  Any assistance will be appreciated.

    I have recently upgraded to iPhone 5 from 4, call line identity doesn't work when call other iPhones.  It works when calling any other brand of cell phone.  Network carrier assures me problem is not on there side.  Any assistance will be appreciated.

  • Signed applet problem with 1.3.1 but same workin in jre1.4

    Hi,
    I have performed the following steps to sign an applet
    1. javac search.java
    2. jar cvf Search.jar *.class
    3. keytool -genkey -alias signFiles -keystore abs_stores -keypass
    123456 -storepass 123456
    4. jarsigner -keystore abs_stores -storepass 123456 -keypass 123456 -
    signedjar SignedSearch.jar Search.jar signFiles
    The applet searches for some files in the hard drive.
    The problem is when I user Jre 1.4,IE 5.5 the applet works but it does not with
    jre1.3.1
    I need it to work with jre1.3.1.
    can someone help me out.
    thanks,
    Anshuman

    I use the following in HTML
    <OBJECT
    classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
    WIDTH = 350 HEIGHT = 300
    codebase="http://java.sun.com/products/plugin/1.3.1/jinstall-131-win32.cab#Version=1,3,1,0">
    <PARAM NAME = CODE VALUE = "Search" >
    <PARAM NAME = CODEBASE VALUE = "." >
    <PARAM NAME = ARCHIVE VALUE = "SignedSearch.jar" >
    <PARAM NAME="type" VALUE="application/x-java-applet;version=1.3.1">
    <PARAM NAME="scriptable" VALUE="false">
    <COMMENT>
         <EMBED
    type="application/x-java-applet;version=1.3.1"
    CODE = "Search"
    CODEBASE = "."
    ARCHIVE = "SignedSearch.jar"
    WIDTH = 350
    HEIGHT = 300
         scriptable=false
         pluginspage="http://java.sun.com/products/plugin/1.3.1/plugin-install.html">
         <NOEMBED>
              </NOEMBED>
         </EMBED>
    </COMMENT>
    </OBJECT>
    thanks,
    Anshuman

  • Signed applet problem: signer information does not match...

    hi all,
    i am actually making a upload component using applets that
    would need to access the local file system for uploading
    files.
    I have created a signed applet(i have followed all the steps,
    such as those of creating a jar, creating a key/value pair
    using keytool and finally signed my jar file using
    jarsigner). when i try to access this applet in a browser,
    first the security certificate displays(which is fine),but
    then when i click on "grant permission", it gives me a error
    saying java.lang.SecurityException: signer information of
    a(particular class of mine)does not match with that of other
    classes in that......(rest is not visible)
    i don't understand why this is happening...i have tried to
    repeat all the steps..but still continues to give this error.
    can anyone help plz...? i am stuck bceauz of this..as the
    JFileChooser dialog box doesn't open up..from which i had to
    browse and select files..
    Thanks in advance
    sd76

    first the security certificate displays(which is fine),but then when i click on "grant
    permission"Not sure what you're talking about, when I sing an applet and open it with IE and jre 1.5
    I get a window titled "Warning - Security". It askes me if I trust the signed applet and
    gives me the options yes, no and allways. But never got the "grant permission dialog".
    Here is how I signed the applet and got it to read local file system:
    http://forum.java.sun.com/thread.jsp?forum=63&thread=524815
    second post

  • Signing applets problem

    ... I did it! kinda...
    my applet is at www.twilightfolk.com/holycrap
    it is signed by a homemade key I aliased as musselman and exported a cert for.
    It's pretty specific to windows users, but the applet simply lists all the files/subfiles in the drive:\folder you specify. It will only look at folders that start with PAT, REL, or EME.
    Somehow I got it working on IE, but it doesn't work in Firefox and my friends can't seem to get it to work on their machines either. Basically if you select a drive with a folder starting with any of the aforementioned strings, it should give you a list of all of the folders named like that in the second combo box. If it doesn't it's a permissions error.
    I created a .java.policy file for this particular certificate, the contents of which is:
    keystore "C:\\Documents and Settings\\djmusselman\\workspace\\Discrepancy\\formshow\\davidstore";
    grant signedBy "musselman"{
              permission java.io.FilePermission "<<ALL FILES>>", "read";
              permission java.io.FilePermission "<<ALL FILES>>", "write";
              permission java.io.FilePermission "<<ALL FILES>>", "execute";
              permission java.io.FilePermission "<<ALL FILES>>", "delete";
    I've got the cert if anyone thinks they need it or wants to try it out. I promise this thing doesn't do anything malicious :-P

    Have you tried signing your applet?
    to sign an applet , you can approach 3d parties like Thawte or you can sign them yourself.
    Package your class file into a .jar, Create your own keystore, sign the jar file using this keystore.
    Then you will be able to open it in a browser.

  • Sign applet problem

    Hi,
    I am following the 10 steps by irene to sign the applet. When I go to number 10, if I want to use self-signed certificate, then i need to import self-signed certificate into the cacerts keystore. However, I don't want my clients to do this thing as they probably don't know how to do this. All I want is my client click the "grant" button and the applet inits. So, are there any other methods to do this?

    Hi,
    I am following the 10 steps by irene to sign the
    applet. When I go to number 10, if I want to use
    self-signed certificate, then i need to import
    self-signed certificate into the cacerts keystore.
    However, I don't want my clients to do this thing as
    they probably don't know how to do this. All I want is
    my client click the "grant" button and the applet
    inits. So, are there any other methods to do this?I dont think so, it would open the flood gates for malicious programs. i can write a program that format ur harddisk, sign it and then give it to you.Cacerts contains a list of CAs trusted by the client. That means, The clients still have to approve/agree/import it.
    In your case, u can give the cacerts file to the clients and ask them to copy it to the lib\security directory.

  • Self Signing and Applets

    I have spent hours reading over the Signed Applets forum and Sun applet security training pages. There seems to be so much confusion in this area that the use and proliferation of Java Applets must be suffering.
    As the usual underfunded developer, I am not able to buy a certificate before proving the concept. Therefore, I am relegated to using self signed applets to demonstrate the use of signed applets and the power they have. This would also be the case for students of Java applets, of which I am also one.
    I have tried the sample applets in the Sun security training. They in fact write the file to my system, but they also display a security error as well.
    The Sun training indicates that I should be using a policy file with the security and that when my applet is run by another user, that user must also manually update their policy file, using keytool, before running the applet. If this is true, I see no use for Java Applets that work outside of the sandbox confines. There must be a better way to use applets that require security.
    I have also read Irene's 10 steps and numerous comments about them. They seem to work fine until I get to step 10. If I am using a self signed applet, why should the user of the applet have to click on a HREF to load the certificate into the keystore? Why shouldn't the user be prompted to trust the self signed certificate, just like a certificate obtained from a CA?
    I have tried to develop a batch file (Windows NT 4.0) to illustrate the signing process, but I have been unsuccessful. I have listed the output from it below followed by the batch file itself. Would someone please indicate what would make this batch file work? If possible, I would like it to work for both IE 5.5 and Netscape 4.06; especially ie 5.5.
    My environment consists of:
    NT 4.0 (SP6)
    IE 5.5 (SP1)
    JRUN 3.1
    JRE 1.3.1_01
    JDK 1.3.1_01
    javac writeFile.java
    keytool -delete -alias writefile
    Enter keystore password: password
    keytool -genkey -alias writefile
    Enter keystore password: password
    What is your first and last name?
    [Unknown]: Robert Klawuhn
    What is the name of your organizational unit?
    [Unknown]: mygroup
    What is the name of your organization?
    [Unknown]: mycompany
    What is the name of your City or Locality?
    [Unknown]: mycity
    What is the name of your State or Province?
    [Unknown]: mystate
    What is the two-letter country code for this unit?
    [Unknown]: US
    Is <CN=Robert Klawuhn, OU=mygroup, O=mycompany, L=mycity, ST=mystate, C=US> correct?
    [no]: yes
    Enter key password for <writefile>
    (RETURN if same as keystore password): password
    keytool -selfcert -alias writefile
    Enter keystore password: password
    keytool -list -alias writefile
    Enter keystore password: password
    writefile, Wed Dec 19 10:41:35 PST 2001, keyEntry,
    Certificate fingerprint (MD5): 90:4D:63:0E:9E:56:CF:7F:93:2B:92:EE:AA:2B:87:E3
    jar cvf writefile.jar writeFile.class
    added manifest
    adding: writeFile.class(in = 1678) (out= 940)(deflated 43%)
    jar tvf writefile.jar
    0 Wed Dec 19 10:41:58 PST 2001 META-INF/
    71 Wed Dec 19 10:41:58 PST 2001 META-INF/MANIFEST.MF
    1678 Wed Dec 19 10:40:46 PST 2001 writeFile.class
    jarsigner writefile.jar writefile
    Enter Passphrase for keystore: password
    jarsigner -verify -verbose -certs writefile.jar
    139 Wed Dec 19 10:42:02 PST 2001 META-INF/MANIFEST.MF
    192 Wed Dec 19 10:42:08 PST 2001 META-INF/WRITEFIL.SF
    1098 Wed Dec 19 10:42:08 PST 2001 META-INF/WRITEFIL.DSA
    0 Wed Dec 19 10:41:58 PST 2001 META-INF/
    smk 1678 Wed Dec 19 10:40:46 PST 2001 writeFile.class
    X.509, CN=Robert Klawuhn, OU=mygroup, O=mycompany, L=mycity, ST=mystate, C=US (writefile)
    s = signature was verified
    m = entry is listed in manifest
    k = at least one certificate was found in keystore
    i = at least one certificate was found in identity scope
    jar verified.
    1 file(s) copied.
    1 file(s) copied.
    1 file(s) copied.
    An error appears:
    java.security.cert.CertificateException: Unable to verify the certificate with root CA
    @ECHO OFF
    REM Doit.bat
    REM
    REM This batch file leads the user through the creating
    REM and signing of an applet class and how it is accessed
    REM from a browser. The applet creates the file: C:\tmpfoo.
    REM
    REM The JRE 1.3.1 plug-in should be installed. See the
    REM control panel for an icon leading to the plug-in.
    REM
    REM This demo is for JRE 1.3.1_01, NT 4 (SP6), HTMLConverter
    REM 1.3, and IE 5.5.
    REM
    REM Run the HTMLConverter 1.3 against the following HTML
    REM file to generate the converted HTML that will support
    REM both Netscape and IE. Get the converter from Sun.
    REM
    REM <html>
    REM <head>
    REM <title> Java Security Example: Writing Files</title>
    REM </head>
    REM <body>
    REM Hi there. There is a signed applet following...
    REM <hr>
    REM <applet code=writeFile.class archive="/writefile.jar" width=500 height=50>
    REM </applet>
    REM <hr>
    REM </body>
    REM </html>
    REM
    REM The following is the code for the applet.
    REM
    REM import java.awt.*;
    REM import java.io.*;
    REM import java.lang.*;
    REM import java.applet.*;
    REM
    REM public class writeFile extends Applet {
    REM String myFile = "/tmp/foo";
    REM File f = new File(myFile);
    REM DataOutputStream dos;
    REM
    REM public void init() {
    REM
    REM String osname = System.getProperty("os.name");
    REM if (osname.indexOf("Windows") != -1) {
    REM myFile="C:" + File.separator + "tmpfoo";
    REM }
    REM }
    REM
    REM public void paint(Graphics g) {
    REM      try {
    REM      dos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(myFile),128));
    REM      dos.writeChars("Cats can hypnotize you when you least expect it\n");
    REM      dos.flush();
    REM      g.drawString("Successfully wrote to the file named " + myFile + " -- go take a look at REM it!", 10, 10);
    REM      } catch (SecurityException e) {
    REM      g.drawString("writeFile: caught security exception", 10, 10);
    REM } catch (IOException ioe) {
    REM      g.drawString("writeFile: caught i/o exception", 10, 10);
    REM }
    REM }
    REM }
    REM
    @ECHO javac writeFile.java
    javac writeFile.java
    REM Generate a selfsigned certificate and put it into
    REM the keystore.
    REM
    REM password = password
    REM first and last name = Robert Klawuhn
    REM org unit = COMPASS
    REM org = Applied Materials
    REM city = Santa Clara
    REM state = California
    REM country = US
    REM The -selfcert option may not be necessary the first
    REM time this is run
    @ECHO keytool -delete -alias writefile
    keytool -delete -alias writefile
    @ECHO keytool -genkey -alias writefile
    keytool -genkey -alias writefile
    @ECHO keytool -selfcert -alias writefile
    keytool -selfcert -alias writefile
    REM
    REM Export the key that was just created into a .crt file.
    REM This is then sent to a CA to obtain a 'real' certificate
    REM which is then imported into the keystore. These are
    REM commented because I am trying to use a self-issued key.
    REM
    REM keytool -certreq -alias writefile -file writefile.crt
    REM keytool -import -alias writefile -file writefile.crt
    @ECHO keytool -list -alias writefile
    keytool -list -alias writefile
    REM Jar the applet
    REM
    @ECHO jar cvf writefile.jar writeFile.class
    jar cvf writefile.jar writeFile.class
    REM Verify the jar
    REM
    @ECHO jar tvf writefile.jar
    jar tvf writefile.jar
    REM Sign the jar
    REM
    REM passphrase = password
    @ECHO jarsigner writefile.jar writefile
    jarsigner writefile.jar writefile
    REM Verify the signed jar file
    REM
    @ECHO jarsigner -verify -verbose -certs writefile.jar
    jarsigner -verify -verbose -certs writefile.jar
    REM The next statements assume that the applet will be
    REM obtained from Macromedia's JRun default server.
    REM
    copy writefile.crt %JRUN_HOME%\servers\default\default-app\.
    copy writefile.jar %JRUN_HOME%\servers\default\default-app\.
    copy writefile.html %JRUN_HOME%\servers\default\default-app\.
    "C:\Program Files\Plus!\Microsoft Internet\IEXPLORE.EXE" "http://localhost:8100/writefile.html"

    I believe I finally found my problem. If I use JRun as a web server and put the applet on the default server within JRun, I am only able to run the applet from a different client. It doesn't seem to load right on the same system as JRun.
    This may be due to other software I have running on my JRun server system, but it finally works.
    For those that are still having problems with self-signing applets, here is a batch file, that I am using, that works for me.
    @ECHO OFF
    REM Doit.bat
    REM
    REM This batch file leads the user through the creating
    REM and signing of an applet class and how it is accessed
    REM from a browser. When the Publish button is pressed
    REM     the selected file is copied to C:\TEMP\BOBK_copy.txt.
    REM
    REM The JRE 1.3.1 plug-in will be installed on the client.
    REM See the control panel for an icon leading to the plug-in.
    REM
    REM This demo is for JRE 1.3.1_01, HTMLConverter
    REM 1.3, and IE 5.5.
    REM
    REM Run the HTMLConverter 1.3 against the following HTML
    REM file to generate the converted HTML that will support
    REM both Netscape and IE. Get the converter from Sun.
    REM
    REM <html>
    REM <head>
    REM <title> Java Security Example</title>
    REM </head>
    REM <body>
    REM Hi there. There is a signed applet following...
    REM <hr>
    REM <applet code=FilePrompt.class archive="/fileprompt.jar" width=800 height=500>
    REM </applet>
    REM <hr>
    REM </body>
    REM </html>
    REM
    REM This applet can be executed by starting the default server in JRun and then
    REM then entering the following for the IE URL: http://K011614:8100/FilePrompt.html
    REM This assumes that JRun is installed and running on K011614.
    REM
    REM The first time the applet is executed, the 1.3.1_02 JRE is loaded if allowed.
    REM The main problem here is the JRE is about 5.3MB and takes a while.
    REM
    REM For some reason, running IE and pointing it to the applet on the same system that
    REM JRun is executing, doesn't work. You have to run it from another client that
    REM references the applet.
    REM
    @ECHO keytool -delete -alias fileprompt
    keytool -delete -alias fileprompt
    @ECHO keytool -genkey -alias fileprompt
    keytool -genkey -alias fileprompt
    @ECHO keytool -selfcert -alias fileprompt
    keytool -selfcert -alias fileprompt
    @ECHO keytool -export -alias fileprompt -file fileprompt.crt
    keytool -export -alias fileprompt -file fileprompt.crt
    @ECHO keytool -list -alias fileprompt
    keytool -list -alias fileprompt
    @ECHO jar cvf fileprompt.jar *.class
    jar cvf fileprompt.jar *.class
    @ECHO jar tvf fileprompt.jar
    jar tvf fileprompt.jar
    @ECHO jarsigner fileprompt.jar fileprompt
    jarsigner fileprompt.jar fileprompt
    @ECHO jarsigner -verify -verbose -certs fileprompt.jar
    jarsigner -verify -verbose -certs fileprompt.jar
    copy fileprompt.jar %JRUN_HOME%\servers\default\default-app\.
    copy FilePrompt.html %JRUN_HOME%\servers\default\default-app\.
    REM The following doesn't seem to work when executed on the same
    REM system as the JRun server. Access the applet from another client.
    REM "C:\Program Files\Plus!\Microsoft Internet\IEXPLORE.EXE" "http://localhost:8100/FilePrompt.html"
    pause

  • Help with passing parameters from a servlet to an applet

    dear all
    i m working on a application which will check weather a file is present in a server (webserver) if it is present then it will take the file name and put it into a drop down list and there is a button on click of which i m taking the call to an applet and then on that i need the file name if it is there then i use it to draw a graph
    i m struck on how to take parameter from Servlet -> Applet
    thanks
    Nakul

    hi,
    I understood your question,The context "servlet" cannot communicate to
    an applet becoz applet runs at clients browswer, rather you can communicate from an applet to servlet(HTTPURLCONNECTION class).
    Well coming to the problem, this is how i have understood your problem,
    basically uou get the list of files from the server using normal servelt programing and you will display in an html LIst box and then click the button to view the graph or chart ,
    then you just want to pass the filename which is there in the listbox to an applet and applet will display some image.
    As we know all that using <PARAM NAME=XX VALUE=YY> WE CAN GET THE VALUE IN APPLET BY USING GETPARAMTER() METHOD. and Im very sure that you are not asking that question. your question is like " both the applets and
    the listboxes will be loaded at once and when he selects one of the file from the list box then without refreshing the page , how to display the graph.
    Im i right?
    If so i guess you have to use javascript to do that stuff, and i think its like gave an id for the tag shown <applet id="yes">
    then in the javascript , you can call the Java applet methods (I have never tried before but seen some demos(i dont have that links- google it for inf))
    but i can give clue like.. trying the <PARAM VALUE=""> IF POSSIBLE
    CHAING THE HTML CONTENT IS POSSIBLE IN IE which is again through javascript by calling yes.innerHTML="<PARAM><PARAM><PARAM><PARAM>..."
    Im sure that you can call Java methods from javascript but i never tried and even you can pass an arguments to it.. Let me check out like
    becoz even im interested to know abt it
    bye
    with Regars
    Lokesh T.C

Maybe you are looking for

  • Iphone not recognizing i'm logged in with same acct.

    I am trying to use my macbook to make calls.  Macbook air is on Yosemite, iphone 5 is on 8.1.  The problem is that when i go into settings-facetime, and try to turn on iphone cellular calls, I get the message "cannot turn on iphone cellular calls - F

  • Report with difference of prices from Inventory Valuation

    Hello! I need report with result from Inventory Valuation: Difference of prices= New price - Current Cost. Report can show last 7 documents and i should choose item code. Can u help me? Greetings from Poland

  • Add an old hard drive to H535

    Hello: I just bought a Lenovo H535, win. 8 after my old Dell Dimension 3000 died and want to place the Dell hard drive into my H535 cabinet but it seems the electrical connections are very different on the H535.  The Dell hard drive lines up with the

  • NetBeans confusion

    What is the difference between NetBeans IDE 5.5 and NetBeans Early Enterprise pack 5.5. Article on: http://developers.sun.com/prodtech/javatools/jsenterprise/tpr/reference/docs/bpel_gsg.html shows a "switch" activity whereas in my installed NetBeans

  • Does WebCenter Spaces support Internet Explorer 9?

    Does WebCenter Spaces support Internet Explorer 9? Will it work in IE9 default view, or is compatibility view required?