Applet will contact website the 1 time only.

Discussion in 'Java' started by Blaine & Alexis, Nov 28, 2007.

  1. Hi,

    I'm trying to make and applet that will contact another website, on
    the click of a button from a webpage. In order to do this I've created
    a Signed Applet below.. Where all the work of contacting the web page
    is done in the shift4 class.

    Anyhow, when I load this applet, it will contact the website (ie the
    code validateCreditCard is run during the init). However when the
    webpage calls this same code I get a security problem (Exception :
    access denied ).

    I would like to have this so it only does validateCreditCard when the
    button is pressed. I only put it in the init for test.. Why does it
    work one way fine, and not the other?

    --- Code in FireFox Browser --
    <form name="shift4" method="POST">
    <applet id="shift4Processing"
    code="com.webrezpro.browser.shift4Test" archive="./dist/
    WebRezProBrowserJava.jar" width="300" height="300">
    <input type="button" value="Test"
    onClick="alert( this.form.shift4Processing.validateCreditCard('http://', 10000,'test=test') )" />

    --Basic Applet Setup
    public class shift4Test extends java.applet.Applet{
    shift4 processing;

    /** Initializes the applet shift4Test */
    public void init() {

    try {
    java.awt.EventQueue.invokeAndWait(new Runnable() {
    public void run() {

    this.processing = new shift4();
    System.out.println( this.validateCreditCard("http://", 11000, "") );

    } catch (Exception ex) {

    /** This method is called from within the init() method to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    // <editor-fold defaultstate="collapsed" desc=" Generated Code
    private void initComponents() {
    jButton1 = new javax.swing.JButton();

    setLayout(new java.awt.BorderLayout());

    add(jButton1, java.awt.BorderLayout.CENTER);

    }// </editor-fold>

    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    // End of variables declaration

    public String validateCreditCard(String URL, int timeout, String

    return this.processing.validateCreditCard(URL, timeout,


    Blaine & Alexis, Nov 28, 2007
    1. Advertisements

  2. On Nov 29, 7:59 am, "Blaine & Alexis" <> wrote:
    > I'm trying to make and applet ...

    ...applets are a lot easier to debug with an URL (not that
    I am deeply motivated to debug applets at this instant).

    As a general comment thouhg, some browsers will consider
    combined applet/JS to be an even higher security concern
    than a trusted applet - doing trusted applet things.

    My first recommendation for this type of thing (broken
    applets) is to search Sun's bug DB using the string
    'applet+browsername'. In this case you might add

    Andrew T.
    Andrew Thompson, Nov 28, 2007
    1. Advertisements

  3. Roedy Green

    Roedy Green Guest

    On Wed, 28 Nov 2007 13:59:12 -0800 (PST), "Blaine & Alexis"
    <> wrote, quoted or indirectly quoted someone who
    said :

    >--- Code in FireFox Browser --
    > <form name="shift4" method="POST">
    > <applet id="shift4Processing"
    >code="com.webrezpro.browser.shift4Test" archive="./dist/
    >WebRezProBrowserJava.jar" width="300" height="300">
    > </applet>
    > <input type="button" value="Test"
    >onClick="alert( this.form.shift4Processing.validateCreditCard('http://
    >', 10000,'test=test') )" />
    > </form>

    I would suggest getting rid of the JavaScript and do all the logic in
    your Applet. See
    for source.

    Alternatively send the number off to the sever with your form to be
    validated. You quadruple your headaches trying to combine paradigms.

    Your Applet can also send the pre-validated credit card number to your
    server. You can do that with SSL or with code such as in the
    Transporter if you don't have SSL. See

    Roedy Green Canadian Mind Products
    The Java Glossary
    Roedy Green, Nov 29, 2007
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. pcouas
    Dec 18, 2010
  2. dorayme
    Gene Wirchenko
    Mar 15, 2012
  3. Beauregard T. Shagnasty
    Beauregard T. Shagnasty
    Mar 13, 2012
  4. idle
  5. Brynn
    Jan 19, 2004

Share This Page