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">
    </applet>
    <input type="button" value="Test"
    onClick="alert( this.form.shift4Processing.validateCreditCard('http://
    java.webrezpro.com/test/t.txt', 10000,'test=test') )" />
    </form>


    --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() {
    initComponents();
    }
    });


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

    } catch (Exception ex) {
    ex.printStackTrace();
    }
    }

    /** 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());

    jButton1.setAction(jButton1.getAction());
    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
    postVars){

    return this.processing.validateCreditCard(URL, timeout,
    postVars);

    }

    }
    Blaine & Alexis, Nov 28, 2007
    #1
    1. Advertising

  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
    'trusted+javascript'.

    --
    Andrew T.
    Andrew Thompson, Nov 28, 2007
    #2
    1. Advertising

  3. Blaine & Alexis

    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://
    >java.webrezpro.com/test/t.txt', 10000,'test=test') )" />
    > </form>


    I would suggest getting rid of the JavaScript and do all the logic in
    your Applet. See http://mindprod.com/applet/creditcard.html
    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
    http://mindprod.com/products1.html#TRANSPORTER

    --
    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
    Roedy Green, Nov 29, 2007
    #3
    1. Advertising

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
    Replies:
    8
    Views:
    12,361
    Denis_IBM
    Dec 18, 2010
  2. dorayme
    Replies:
    7
    Views:
    5,828
    Gene Wirchenko
    Mar 15, 2012
  3. Beauregard T. Shagnasty
    Replies:
    0
    Views:
    480
    Beauregard T. Shagnasty
    Mar 13, 2012
  4. idle
    Replies:
    0
    Views:
    504
  5. Brynn
    Replies:
    1
    Views:
    554
    Brynn
    Jan 19, 2004
Loading...

Share This Page