Results 1 to 3 of 3
  1. #1
    snoopy11 is offline Member
    Join Date
    Mar 2011
    Posts
    4
    Rep Power
    0

    Default Pass variable from program to web page

    Hi,

    ive currently got a java swing program that has some text fields for a user to enter text into and then there is a button which when clicked opens up a web page which is displayed within a jeditorpane on a jframe (not the most elegant approach i know but it suits my purposes well enough).

    im trying to find out whether its possible to pass what has been entered by a user in the text fields to forms on the web page that opens. ive had a search and cant really seem to find a huge amount about this specific problem. id really appreciate some advice on whether it is possible and some help or a point in the direction to which i should be looking.

    thanks in advance,
    stephen

  2. #2
    Stamoulohta is offline Member
    Join Date
    Mar 2011
    Posts
    26
    Rep Power
    0

    Default

    I would try to google "Mechanize for java"...

    Disclaimer: This idea has derived from knowledge of other languages. Mechanize or any equivalent may not be the best tool for use in java but it may be a good starting point for your search.

    Cheers.

  3. #3
    ozzyman's Avatar
    ozzyman is offline Senior Member
    Join Date
    Mar 2011
    Location
    London, UK
    Posts
    797
    Blog Entries
    2
    Rep Power
    4

    Default

    The web page should use an applet which, when requested, gets the information required from the java program and passes it to a variable in your HTML/JavaScript.

    Java Code:
    import java.applet.*; 
    import java.awt.*; 
                 
    public class appletParameter extends Applet {
      private String strDefault = "Hello! Java Applet.";
      public void paint(Graphics g) {
        String strParameter = this.getParameter("Message");
        if (strParameter == null)
        strParameter = strDefault;
        g.drawString(strParameter, 50, 25);
      } 
    }
    HTML code:
    Java Code:
    <APPLET code="appletParameter.class" width="800" height="100">
    <PARAM name="message" value="Welcome in Passing parameter in java applet example.">
    </APPLET>

Similar Threads

  1. pass a variable from one object to another
    By kev670 in forum New To Java
    Replies: 3
    Last Post: 11-25-2010, 01:20 AM
  2. Replies: 2
    Last Post: 04-18-2010, 04:48 AM
  3. How to pass a variable to another frame.
    By DJCali in forum New To Java
    Replies: 10
    Last Post: 10-14-2009, 03:57 AM
  4. How pass variable from jsp to servelet
    By shiva in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 04-22-2009, 01:55 PM
  5. How to pass an html variable as an applet value
    By fred in forum Java Applets
    Replies: 1
    Last Post: 08-06-2007, 03:28 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •