• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java HTML auto submit

 
Sandy Schneider
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sending a user query request to a Vendor's URL to receive a query reply back.
I am writing a servlet that writes a HTML form that goes to the Vendor's URL.
I've dealt with servlets that are initiated by a user and output HTML where the user submits the form data. Our situation is different. First, we have to somehow initiate the Servlet from a class. Second, the html must somehow be auto-submitted (without user-interaction). All this must be done behind the scenes without any user interaction.
Can anyone help?
Sandy
 
Steve Granton
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm not sure whether there is a better or more efficient way to do it but we created a URL object on the required query string in the class and then opened the connection using the URLConnection object.
We then read the response from the connection.
We used this to lookup a users address by the postcode.
An example of the code is below
I hope this helps
Cheers,
Steve
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that when you open a URL with a string starting "http://" you actually get a HttpURLConnection object. This allows you to set all of the regular HTTP headers in case the URL you are sending to requires them.
Bill
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic