Java program to automatically fill out and submit a Web form

I need to write a program to set the fields of a Web form and submit it automatically.
Can anyone help?
Thanks in advance!

heres some code I have been messing about with
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.security.*;
import java.net.*;
/** Author :James Charles 20/03/2004
This module handles the customer booking screen **/
public class Bookings extends Applet implements ActionListener,   // sets up the initial display screen
ItemListener
     Choice details;
     TextField name;
     TextField telephone;
     TextField email;
     TextField address;
     TextField postCode;
     Color webPage = new Color(0,128,255);
     Button btnClick;
     String nameOutput =" ",telephoneOutput=" ",emailOutput=" ",addressOutput=" ",postCodeOutput=" ";
     int jobNumber;
     int authorisationCode ;
     Font formEntry = new Font("SanSerif",Font.BOLD,15);
     Font dataDisplay = new Font("SanSerif",Font.PLAIN,16);
     boolean dataEntry = false;
     int position = 2;
     String[] detailsOutput = { "Choose a Subcontractor","Painter & Decorator","Electrician" };
     public void init(){
          readJobNumber(jobNumber);  // reads the las job number from file jobNumber.dat
          Button btnClick = new Button("Submit Details");
          setBackground(webPage);
          add(new Label("                           Name"));
          name = new TextField(30);
          add(name);
          add(new Label("                           Telephone"));
          telephone = new TextField(25);
          add(telephone);
          add(new Label("House No"));
          address = new TextField(3);
          add(address);
          add(new Label("Post Code"));
          postCode = new TextField(8);
          add(postCode);
          add(new Label("E-Mail address"));
          email = new TextField(35);
          add(email);
     public void start(){
          add(new Label("                                                                       Please choice the appropriate Tradesman that you require"));
                    // choice code set up
          details = new Choice() ;
          details.addItemListener(this);
          details.add("Choose a Sub Contractor");
          details.add("Painter & Decorator");
          details.add("Electrician");
          details.select(0);
          add(details);
          btnClick = new Button("Submit Details");
          btnClick.addActionListener(this);
          add(btnClick);
          btnClick.setEnabled(false);
     public void actionPerformed(ActionEvent e) {
          System.out.println("Was in action performed event =" + e);
          dataEntry = true;
          nameOutput = name.getText();
          telephoneOutput = telephone.getText();
          emailOutput = email.getText();
          authorisationCode = (int)(java.lang.Math.random() * 100000);
          if (dataEntry == true){
               btnClick.setEnabled(false);
               repaint();
               System.out.println("In between paint and write");
               WriteBookings(nameOutput,telephoneOutput,emailOutput);
     public void itemStateChanged(ItemEvent e) {
          position = details.getSelectedIndex();
          System.out.println("Position in itemStateChanged after getSeletedIndex = " + position);
          btnClick.setEnabled(true);
          repaint();
     public void WriteBookings(String nameOutput,String telephoneOutput,String emailOutput)   {               
                   writeJobNumber(jobNumber);
          try{     
               DataInputStream in = new DataInputStream(new      FileInputStream("CustomerDetails.txt"));
               char singleChar;          
               DataOutputStream out = new DataOutputStream(new FileOutputStream("CustomerDetailsNew.txt"));
          /**     try {
                    jobNumber =in.readInt();            // this code reads last job number and increments it
                    singleChar = in.readChar();
                    jobNumber ++;
                    out.writeInt(jobNumber);
                    out.write('\n');
                    while (true){                           // this code
                         singleChar = in.readChar();
                         out.writeChar(singleChar);
               catch (EOFException e) { }
          out.writeChars(nameOutput);
                out.writeChar('\t');
          out.writeChars(telephoneOutput);
                out.writeChar('\t');
          out.writeChars(emailOutput);
          out.writeChar('\t');
          out.writeInt(jobNumber);
          out.writeChar('\t');
          out.writeInt(authorisationCode);
          out.writeChar('\t');
          out.writeChars(detailsOutput[position]);
                out.writeChar('\n');
          out.close();             
       catch (IOException e){
          System.out.println("Error: " + e);
          System.out.println("Close File"); //*********** End of read/write process, code below renames the new file to the input file
          File fileDelete = new File("CustomerDetails.txt");
          fileDelete.delete();
          try{     
               DataInputStream in = new DataInputStream(new      FileInputStream("CustomerDetailsNew.txt"));
               char singleChar;          
               DataOutputStream out = new DataOutputStream(new FileOutputStream("CustomerDetails.txt"));
               try {
                    while (true){
                         singleChar = in.readChar();
                         out.writeChar(singleChar);
               catch (EOFException e) { }
           catch (IOException e){
          System.out.println("Error: " + e);
     public void readJobNumber(int JobNumber) {
                   StringWriter sw = new StringWriter();
                   PrintWriter  pw = new PrintWriter(sw);
          try {
               //URL ftpUrl = new URL("ftp://j-charles:[email protected]/jobNumber.dat");
                        //InputStream inFile = ftpUrl.openStream();
               URL ftpUrl = new URL("ftp://jim:evvcece@/jobNumber.dat");
                       InputStream inFile = ftpUrl.openStream();
               BufferedReader in   =  new BufferedReader (new InputStreamReader (inFile));
               String line = null;
               while ((line = in.readLine()) != null) {
               System.out.println(line);         }
               in.close();     
               catch (IOException e) {
                     System.out.println("Reading Job number error " + e);} // catches IO exception
     public void writeJobNumber(int JobNumber) {
          try {
               URL ftpUrl = new URL("ftp://j-charles:[email protected]/jobNumber.dat");
                       URLConnection conn = ftpUrl.openConnection();
               conn.setDoOutput(true);
                       OutputStream out = conn.getOutputStream();
               System.out.println("writing job number" + jobNumber);
                       PrintWriter writer = new PrintWriter(out);
                       System.out.println("Writing to ftp");
               writer.print(jobNumber);
               writer.print('\n');
                       writer.close();
               out.close();
               catch (IOException e) {
                     System.out.println("Job number error " + e);} // catches IO exception
     public void paint(Graphics g){
          if (dataEntry == true){
               System.out.println("Calling paint");
               g.setFont(dataDisplay);
               g.drawString("Our allocated " +  detailsOutput[position] + " will contact you within 24 hrs", 10,200);
               g.drawRect(0,260,650,50);
               g.drawString("Your details are as follows:", 10,280);
               g.drawString(nameOutput, 10,300);
               g.drawString(telephoneOutput, 200,300);
               g.drawString(emailOutput, 400,300);
               g.drawString( "Job#" + jobNumber, 10,400);
               g.drawString("Authorisation Code:- " + authorisationCode, 200,400);
               g.setFont(formEntry);
               g.drawString("Please keep note of the job number and authorisation code to enable you to use the job tracker screen.",10,450);
          dataEntry = false;
}

Similar Messages

  • How to fill out and submit a web form using LabVIEW

    Almighty Forum,
    This question will require knowledge not only of LabVIEW, but also of HTML, JavaScripting, and possibly more.  I don't know about you, but I have an on-line account for pretty much everything: Bank, Credit Card, Savings, ETrade, 401K, Roth IRA, etc.  About once a day I want to go and check on everything (because I'm an anal engineer), but it takes so freaking long to navigate and login to each site.  Even after favoriting all the links and using cookies to save my "username", I still have to type in my password, hit enter, and wait for each site.  This takes time, time is money, and money is why I'm doing this in the first place; so, I need a better solution.  And since I stand by LabVIEW, I want a LabVIEW solution. 
    The solution in my head is something like this.  I have one front panel with an embedded IE browser (in an ActiveX container).  On the side of the browser I have my "favorite" toolbar.  When I click on a button in the toolbar, it takes me to the site and automatically logs me in.  Simple.  Now once that is working I could make a single app with no browser interface that simply went out and queried all my sites for the important values and displayed them on the front panel.  But not to get ahead of myself, I'll stick with my first goal for now.  Baby steps.
    So here is what I have now.  I can load www.bankofamerica.com into my browser and automatically enter my "online ID" and "passcode".  I just can't seem to figure out how to submit the form.  I realize that I could just simulate a mouse click on the coordinates of the Sign In button, but that would not be nearly elegant enough for me to have pride in this application. 
    If you run the VI that I'm posting, and click Submit Info, you are taken to a error page saying something along the lines of "We're temporarily unable to process this request.  Please try again."  Now this would probably make sense with the "dummy" ID and passcode that is being used in this VI, but I get the same thing when I use my real information.  I'm beginning to think that this is something BOA has done to prevent people from logging in programmatically.  That would probably make sense to deter potential hackers.
    There's got to be a way...  can you help?  This might take some time, but think how it could help streamline you in the long-run
    PS:  I down-converted the VI to 7.0 format for anybody stuck in 2003
    Thanks,
    Travis H.
    Travis H.
    LabVIEW R&D
    National Instruments
    Attachments:
    Bank of America Login - test.vi ‏179 KB

    Otman wrote:
    Simply stated, you want to hit some button on your app and instantly see all your accounts no matter where from, is that correct?
    Hi Otman,
    Actually, my first goal is to be able to hit a single button that automatically logs into a single account.  For example, when Bank of America Login - test.vi (attached above) is run, it should automatically:
    1) Navigate to www.bankofamerica.com
    2) Programmatically enter the "Online ID" and "Passcode"
    3) Submit the form and log in
    Its step 3 that I'm having trouble with.  Again, see the VI attached to my first post for a good example of what I'm talking about.
    Thanks,
    Message Edited by Travis H. on 11-16-2005 10:27 PM
    Travis H.
    LabVIEW R&D
    National Instruments

  • Please Help--Can't fill out or submit/save .PDF forms

    Hi-
    Running Safari 5.1.2 on Mac OS 10.6.8 (the latest updates according to software update) and using the Schubert PDF browser plugin. http://www.schubert-it.com/pluginpdf/
    Before updating from Safari 5.0.xxxx I could fill out and submit .PDF forms in Safari without any issues. Now, I cannot. The form comes up but I cannot enter any text into the text fields.
    About a month ago I went through this and had to revert back from a time machine back up because the ability to fill out forms in browser is an everyday necessity for me.
    Does anyone know how to fix this issue?? Please help...

    Ok.. I still cannot get this figured out. I'm baffled and frustrated!!
    I did a deep cache cleaning using Snow Leopard Cash Cleaner, all of your reccomendations, and about an hours worth of reading. I had the schubert-it plug in uninstalled and have gone back to reinstalling it with no luck. I was thinking after all the cache cleaning it might work. Nope..
    I can't beleive this is an issue after an update.. Apple is normally so great with this stuff.
    The com.adobe.reader folder does not exist on my computer.
    This problem occurs with any online form, not just the ones I need to access and submit, and it occurs with the native PDF support in Safari as well as the schubert app.
    Any other ideas? I read on one post where someone fixed it with quicktime, but the video he put up to show how he fixed it was no longer available.
    Carolyn, or anyone else, .. any ideas??

  • Created a form in Forms Central. Exported the PDF with Submit Button Option. When the PDF is filled out and submit clicked, it comes back asking for required fields to be filled but they already are. Any Help?

    b

    Hi;
    OK - I can clarify some things and tell you how to do what your looking for. 
    The desktop FormsCentral application tools are really designed towards create forms that do collect data on FormsCentral servers.  You can still easily create PDFs that do not submit data to FormsCentral, but you'll have to add any alternative submit functionality using the Forms tools in Acrobat.  You can create a PDF without the submit button in either case, signed in/out of the Desktop Application from the "File" - "Save as PDF Form" menu item.  You can then modify the PDF in Acrobat XI Pro by doing a "Save A Copy", when you open the copy you can edit it any way you like, adding a "Submit" button that email's the PDF/Responses back to you...
    Here's how: In Acrobat open the PDF you saved from the FormsCentral Desktop application and go to "File" - "Save a Copy" and choose a location, this will remove the security.  Open up the copy you just created and you can now edit it, here is a YouTube video tutorial using Acrobat XI, he covers the email button in about two minutes, there are lots of tutorials out there but this one is easy to follow:,
    http://www.youtube.com/watch?v=Jql1wp5Gofs
    Thanks,
    Josh Corey
    FormsCentral Team

  • What do I need to fill out and print a PDF form?

    I need to type on this form save and print it, how do I do that?

    Hi nette7,
    To fill in, save, and print your form, you can use the free Adobe Reader. You can download the free Reader from here: PDF reader, PDF viewer | Adobe Reader XI.
    Of course, if you have a full version of Acrobat, you can use that as well. But Reader will definitely give you the tools you need to get the job done.
    Best,
    Sara

  • How can I embed a form on my website and set up a submit button so that when people fill out and click Submit, the filled form will be emailed to me as an attached pdf file?

    How can I embed a form on my website and set up a submit button so that when people fill out and click Submit, the filled form will be emailed to me as an attached pdf file?
    Thank you!

    Hi;
    That is not a workflow that is supported by the Adobe forms solutions at this time.
    Thanks,
    Josh

  • Form for my visitors to fill them out and submit them via email

    Hello, I need to have several forms in my website and allow my visitors to fill them out and submit them via email, can I use FormCentral?
    This is my website:
    http://aiiav.org/cemetary/forms/
    Thank you
    Juan Pulido

    Hi;
    You could certainly use FormsCentral. 
    FormsCentral allows you to easily create forms that you can distribute either using a web form with a "Submit" button that sends the data back to FormsCentral and is available in your account for you to view and analyze, or you can also distribute the form as a PDF.  The PDF can have a FormsCentral "Submit" button that (same as with the web form) sends the data back to FormsCentral, or can be saved without a Submit button allowing you to add your own Submit button using Acrobat which could be an "Email" submit button (which would email you the form data or the entire PDF).
    If you chose "web forms" you could embed the form into your website for users to fill out right there and submit without having to send via email.  You could have links to each embedded form on your site.
    Here is an overview of FormsCentral, I'd be happy to answer any follow up questions: http://forums.adobe.com/docs/DOC-1413
    One note if you were to use PDF - your current PDF forms are set to open in the web browser.  If you used FormsCentral PDF forms you would want to have a link that downloads the PDF to the users computer so they can fill out in Adobe Acrobat or Adobe Reader, filling out in the web browser, or with any other PDF viewer does not work correctly and is not supported.  You would want to call that out on the download page to ensure users fill out in Adobe Reader.
    Thanks,
    Josh

  • How Do I Add A PDF That Can Be Filled Out And Submitted To My Email

    I just finished converting an application to PDF using the forms wizard. This works really well as it makes it so they can only fill in the required information and not alter any of the other form. Right now I just have it posted as a downloadable file that they can save fill out and email back in. However what I'm wanting to do is have it where they can just open the PDF in another tab, fill it out and hit submit and have that automatically sent to my email account. What I've done is use:
    <a href="digital_application.pdf">Click To View</a>
    This in essence will open the application in another tab of the browser where they can fill everything out. However thus far their only option is either a "Print" or "Save" button. I'd like to add a "Submit" button somehow to where it's emailed to an account I've set up, or have it save to a file on the server. I don't know if this is something I have to code into the site, or If I can make a button on the PDF itself, or there's an option to make the PDF display a "Submit" button, just need a little help. Thanks!

    You use the 'submit' method to submit the PDF's FDF to web based script page and have that page perform the email function.
    http://www.planetpdf.com/developer/article.asp?ContentID=Web_Hosting_PDFs&gid=6526

  • How can java programs execute automatically when it connects to network

    Good Day dears...
    How can java programs execute automatically when it connects to network.
    Thanks in Advance friends Shackir

    884924 wrote:
    Good Day dears...
    How can java programs execute automatically when it connects to network.What is "it"? That is, execute when what connects to the network?
    Your computer? If that's what you mean, this is not a Java question. It's an OS operational/administrative question. Executing any program, whether written in Java or not, based on some system event has to do with that system, not with the program. If it's possible to do this, you'd do it exactly the same way for a Java program as you would for any other program.
    Or is "it" the program itself? If this is what you mean, then it's a nonsensical question. For the program to connect to the network and detect that it has connected to the network, it must already be executing, so asking how to execute it at that point is meaningless.
    Finally, I'll point out that "connecting to the network" is a pretty meaningless phrase. Or rather, it has so many potentially valid meanings that it's impossible to know which one you're referring to when you use that phrase. And I'd be willing to bet you don't have a clear picture of that yourself.

  • Create a Form in Acrobat Standard that can be filled out AND SIGNED using Free Reader

    I am tasked with creating forms that can be read, filled out and signed and submitted electronically by users that have only the reader software. I am using Acrobat 5 standard. I have not yet found a way to successfully create a form field that would allow users to insert a signature of some sort. This signature does not have to be encrypted, or use the digital signature system Adobe Acrobat has where you create a profile, log in, etc. It could be as simple as the ability to insert a jpeg or other image of their handwritten signature. This is to avoid having to have them fill it out, and then print it and fax or scan it in. It would be great if they could fill it out and then just save it and email it. How would I do this, or is it even possible?
    Thanks,
    JOhn

    With AA5, there is no capability to submit a signature - even electronic. You can create a form that can be filled out, signed in the sense of adding a name and date, and submit to a web site.
    Insertion of images is not part of forms with AA5, but I think has become possible recently. Even so, they reader would also have to be compatible with the feature to be able to use it. If the typing of the name and the date would do, then you can add those fields - sort of the limit with AA5.
    With AA5, they can not save the form with the data. They can submit the data as an FDF file to a web site. If you have control of the client machines, then you can consider e-mail since those issues can be worked out locally. Without control of the clients (like a general form on the web), don't bother with e-mail since there will always be some that have problems.

  • Create a Doc for Filling Out and Sending On

    I'm trying to create a document for pricing quotes.
    The idea is that I (designer) create a document (writable) for a client to fill out, save (unwritable), and send to customers for price quotes.
    I've tried:
    creating text boxes - but when the document is filled out and saved, the client is still invited to change the fields (we don't want that!)
    creating signature boxes - which pulls up a lengthy and complicated signature field
    signing the document with multiple signatures - a hassle I wouldn't wish on a client
    going to the "sign" field of Adobe Reader, clicking "Add Text," and saving the document. - The save option still leaves the text editable upon reopening; the email option requires an echo account, which we're not looking for because we aren't actually creating legal documents.
    Any advice? I could really use it!George Johnson was helping before, when I hijacked Island Lady's thread (eep! sorry about that!)
    I'm using InDesign to create the document, saving into Acrobat Pro, and and/or reading in Adobe Reader (which my client will be using).
    A sample of the document is HERE

    Here are the preliminary instructions I'm sending to my client:
    Open the Document in Acrobat Reader 11.0.07
    Click on “Sign.”
    Click on “Place Signature” -or- if you’ve already done this once, click on the corresponding arrow, then click on “Change Saved Signature”
    Select “Type my signature”
    Type the word/s you would like to type in the “Enter Your Name” field (never mind that it’s not your name )
    Click “Accept”
    Drop the word/s in the text field you would like them to go in.
    Repeat until the form is filled out.
    Click “Signed. Proceed to Send”
    Click on “Save a Copy”
    Rename your document so that a copy is saved for you to email to the customer.
    Email your document using your own email program.
    Finished!

  • I need help to find and open a job app that I exported, was able to fill out and sign and saved and now can't open it? What did I do wrong?

    I need help to find and open a job app that I exported, was able to fill out and sign and saved and now can't open it? What did I do wrong?

    What file format did you export it to?

  • Is there a way to create a PDF form that ANYONE can fill out and SAVE with their content?

    Is there a way to create a PDF form that ANYONE can fill out and SAVE with their content? By anyone, I mean someone who can download and use the free Adobe Reader, on either a Mac or PC. I have Acrobat Pro, and would like to be able to create forms that can not only be filled out and printed, but saved and emailed, which is not an option with the forms I have created to date. They can be filled out, but not saved, with Adobe Reader.
    TIA,
    Nancy

    To do what Dave indicated you need to do, it depends on what version of Acrobat you have:
    Acrobat 8: Advanced > Enable Usage Rights in Adobe Reader
    Acrobat 9: Advanced > Extend Features in Adobe Reader
    Acrobat 10: File > Save As > Reader Extended PDF > Enable Additional Features
    Acrobat 11: File > Save as Other > Reader Extended PDF > Enable More Tools (includes form fill-in & save)
    I wonder what it will be next time?

  • Can I make a form that could be emailed filled out and returned

    I'd like to create a form that I can email my students and that they could fill out and return.
    Is there a site or video that could help me learn this?
    Perhaps create a template?

    Not in Pages, except to create the basic form itself.
    The best method is create a pdf form, using Acrobat Pro to fill in the data fields of the form.
    The students can use the free Acrobat Reader to fill in the fields, which you can have sent electronically back to you or whatever database you want, or as a simple dumb form that accepts their typing.
    To have a quiz style multiple choice document, that even corrects and sums up results use iBooks [free], very similar to Pages, or a dedicated application for this style of work.
    Peter

  • I cannot open a form that has been filled out and email back to me.

    Hi,
    I created a form in Adobe 8 with an email link.  When the form is filled out and emailed back to me, I am unable to open it in a readable format.  It is sent back to me in an XML Document.
    I am new to this - can anyone help me please??

    I hope its not preview.

Maybe you are looking for

  • Problem when execute report Conversion Tool XI 3.0 on a client

    Hi everyone, When I use Report Conversion Tool on a client (not on Webi Server Windows 2003) I have an error (a red cross appears) before the conversion. I believe that RCT can not open the document to migrate. All it's OK when I use RCT since the We

  • Different Versions of JWS Don't work with my jnlp - please help!!

    I had jdk1.5.0_14 installed with IIS serving a jnlp file that indicates the java version must be 1.5. I can download and run my application from a web page. I installed jdk1.6.0_02. JAVA_HOME and the path environment variables both point to jdk 1.5.

  • Experience in programming LabVIEW with HP E1432A

    Can someone share his/her experience in controlling HP/Agilent E1432A VXI module? The last posting on the forum about HP E1432A was dated in 2001. I know NI has a LabVIEW plug&lay instrument driver (wrapper) now for the E1432A module. How easy is it

  • Why does the top and bottom of my clips get cut off?

    Hi, I'm new to iMovie and I've encountered an annoying problem. I imported all my movie files from my flash drive without any issues. I dragged a clip from the section with all the clips to the play reel. I previewed the clip, both normal screen and

  • Re: attachments from Outlook calendar

    I also synchronize my personal Blackberry 8830 phone manually.  Any attachment to my Outlook calendar will not synchronize as a readable attachment on my Blackberry calendar.  Is there software I can add that will allow me to open and view attachment