This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "java HTML auto submit" Watch "java HTML auto submit" New topic
Author

java HTML auto submit

Sandy Schneider
Greenhorn

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?
Sandy
Steve Granton
Ranch Hand

Joined: Jan 13, 2002
Posts: 200
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

Joined: Mar 22, 2000
Posts: 12761
    
    5
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java HTML auto submit
 
Similar Threads
HTML display
Session Timeout w/o xml?
creating HTML with Java
submit html for via applet
How to upload a file to a http server on the web.