File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes java HTML auto submit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "java HTML auto submit" Watch "java HTML auto submit" New topic

java HTML auto submit

Sandy Schneider

Joined: Mar 14, 2002
Posts: 22
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?
Steve Granton
Ranch Hand

Joined: Jan 13, 2002
Posts: 200
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
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
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.
I agree. Here's the link:
subject: java HTML auto submit
It's not a secret anymore!