• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

posting a form automatically

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to submit a form with username and password to automate the login process but I'm stuck... I need to return the new URL after the form has been submitted. I've tried the following and don't get any errors but it doesn't return anything.
URL url = new URL("https://manager.verisign.com/login/loginaction.cfm");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setFollowRedirects(true);
connection.addRequestProperty("partnerid","partnerid");
connection.addRequestProperty("login","login");
connection.addRequestProperty("password","password");
connection.connect();
Any help would be appreciated.
Thanks,
Dave
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With addRequestProperty you are creating request header lines - not the same as what the servlet request contains when a form is submitted - which a program retrieves with getParameter("useid") - etc.
With a GET request, the parameters come as part of the URL (you can see this in the URL for this page). With a POST request, the parameters come in the body of the request (after the headers) as name=value pairs
Bill
 
Dave Bosky
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So to automatically submit a prepopulated form to a website I need to do what? Do you have a simple example? Which classes do I need to use to accomplish this task? I'm pretty frustrated... I've been looking for an example of which classes to use and have come up dry all day long.
Thanks Again,
Dave
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whenevr I need to "remote control" another website I use HttpUnit it's positioned as a web testing tool, but is actually very good at controlling web applications, building and sending data, and processing the replies.
One of my recent articles in The JavaRanch Journal covers a simple introduction how to do this.
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well since Frank has mentioned HttpUnit, I am obligated to mention the HttpClient toolkit - part of the Jakarta Commons project. which I have used to mimic form submission when load testing servlets.
Bill
 
reply
    Bookmark Topic Watch Topic
  • New Topic