DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 7 of 7

Thread: Post&submit text to a form in java

  1. #1
    Join Date
    Aug 2005
    Posts
    2

    Post&submit text to a form in java

    Hello all,

    I am a Java developer and am wondering how do I use a java program to post to form and fill in some text on webpages?
    example: do a program that posts a message to:

    http://long_john321.t35.com

    thats a site done by me to test this.

    I would be thankful if anyone would tell me how to do this or give a hint to a program w/ source, howto, tutorial or book.
    Thanks!

  2. #2
    Join Date
    Jul 2005
    Location
    the Netherlands
    Posts
    128
    Quote Originally Posted by long_john321
    I would be thankful if anyone would tell me how to do this or give a hint to a program w/ source, howto, tutorial or book.
    Thanks!
    Here's a link to some opensource web-crawlers written in Java:
    http://www.manageability.org/blog/st...lers-java/view

    Good luck.

  3. #3
    Join Date
    Jul 2005
    Location
    SW MO, USA
    Posts
    299
    Not sure what you are asking.
    Is the code you want going to run on a server or on a client?

    On a client your java program would do a HTTP GET to a server, get its HTML with the <FORM and then create the needed response and send it back to the server following the rules specified in the ACTION= tag.

  4. #4
    Join Date
    Feb 2005
    Posts
    55
    What you need to do is JSP and servlets.
    JSPs are webpages with java built in and servlets are used to use information in a form. There are two types of methods POST and GET both do the same thing. If you research servelts and JSPs they should be of help to you.

  5. #5
    Join Date
    Aug 2005
    Posts
    2
    Okay thanks for all the good info! But I think some ppl have misunderstood my question:
    These are the premises:
    *It needs to work for a PHP site (like the one I made) /no jsp,cgi
    *I dont need to have the sourcecode, that means the program is like doing it "manually" in a webbrowser but no clicking.
    *pure client-side program of course

    Short summary: if you cant get the idea/program/pseudocode to work for my site I provided then its not the right program, im afraid

    And Norm, could I get some pseudocode on that idea you had?

  6. #6
    Join Date
    Aug 2005
    Posts
    8
    client to web, auto...let's see:
    - client wsave some data to a db, put a status flag=0
    - on load, let the form web page xtraxt from a db, change the flag to 1

    workable?

  7. #7
    Join Date
    Jul 2005
    Location
    SW MO, USA
    Posts
    299
    I assume that the java program you are talking about will run on a client machine and will do what a user might do with a browser. Ie read a web page with a <Form, fill in the fields/check the boxes and submit the results to the server.
    I don't know how to parse an unknown <Form. Perhaps there are classes to do that.
    If you know what the <form looks like, you can build a URL with the response fields set as needed and send it back to the server.
    If there is a parser for the HTML <Form, then the job is a little harder, but doable.
    In the doc you need to look at the format for the URL sent by a client when 'Submit'ing a <form.
    There is GET and POST to consider.
    There also might be Cookies to return to preserve state on the server.

Similar Threads

  1. Replies: 2
    Last Post: 04-17-2009, 11:14 AM
  2. Has Sun Given Up on the Desktop?
    By Lori Piquet in forum Talk to the Editors
    Replies: 114
    Last Post: 10-10-2002, 06:01 AM
  3. .NET vs. Enterprise Java: Who's Got Better Security?
    By Glen Kunene in forum Talk to the Editors
    Replies: 17
    Last Post: 03-23-2002, 01:43 AM
  4. Reading text files in Java
    By Khalid Al-Tayaran in forum Java
    Replies: 1
    Last Post: 02-18-2002, 08:24 PM
  5. Double Text 1.0
    By George Gilbert in forum vb.announcements
    Replies: 0
    Last Post: 08-19-2001, 11:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center