Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help forcing javascript form to post from java program  RSS feed

 
Matt Senecal
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know how I can go about this? The form in question doesn't use a cgi script.
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't really understand what you want to do. I guess you are generating some sort of form (maybe HTML?) from a Java program (is it a servlet?) and want to make it send a POST request.
That seems simple: < form method='post' action='some url' >
You say the form "doesn't use a CGI script" - so what does it send its contents to? a mailto: URL? a servlet?
Please let us know a little more about what you need.
 
Matt Senecal
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using a java app to make a http connection to a web server and to download a page. The page has a javascript form on it. Using my java application I need to fill out the form and submit it. I have no idea how to do this.
The form is not posted using a cgi script. What is it posted with? I have no clue. The tag for the form looks like this:
<form action = "hello.asp" method = "post" onSubmit = "return FrontPage_Form1_Validator(this)" name = "FrontPage_Form1">
Any ideas?
 
Matt Senecal
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whoops! try this post instead!
I am using a java app to make a http connection to a web server and to download a page. The page has a javascript form on it. Using my java application I need to fill out the form and submit it. I have no idea how to do this.
The form is not posted using a cgi script. What is it posted with? I have no clue. The tag for the form looks like this:
form action = "hello.asp" method = "post" onSubmit = "return FrontPage_Form1_Validator(this)" name = "FrontPage_Form1"

Any ideas?
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your form is processed using an ASP page (it's in the "action" attribute). Don't worry about it not being a CGI script, the protocol is the same.
To "fill out" such a form from a Java application, you need to be able to read in the HTML for the page, parse it so you can find the form definition, and the definitions of all the "input" and "textarea" fields in it.
Once you have all of that, you need to build a HTTP POST request and submit it to the ASP server. Then presumably you need to read and parse the reply ...
None of this is particularly easy, and you will need to do a lot of study on HTML and HTTP to get the details right and make sure your program is robust enough to handle whatever may be on the supplied page. And realistically you have no way to execute the JavaScript validation, so I hope you don't need to do that.
Good luck.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!