HTML POST - Getting resulting page

I have three questions about submitting forms using POST.

1. When there are several fields named "example[]" how do I submit values?

2. How do I wait until the POST is complete? The form uploads files. Is there something I can do (other than a simple timer) to make sure the files have completed before starting the next? Or should I just do one at a time?

3. I'm confused about what happens after I submit the form. Basically...what do I do? Do I just make another URLConnection and what not? The page that I need to get is generated depending on what I upload.

Thanks. And I did search a lot before I posted this so I'm sorry if I missed something.

[683 byte] By [gometro33a] at [2007-10-3 4:38:31]
# 1

To find out how to do 1 create a form with request method get and several fields with same name and submit it. Ans see what is send in the query string.

You should be able to do it same way in the request body of a Post request.

Dont use the timers. Once you are done writing the request take the InputStream from the URLConnection and read it. Or you can get the response code. Either way it will block until the server sends the response.

To get the out put of the server you can take the InputStream of the URLConnection and read it.

LRMKa at 2007-7-14 22:42:21 > top of Java-index,Java Essentials,Java Programming...
# 2
I'm sorry but I don't think I understood anything you wrote...
gometro33a at 2007-7-14 22:42:21 > top of Java-index,Java Essentials,Java Programming...
# 3
Just search the forums you will get plenty of samples
LRMKa at 2007-7-14 22:42:21 > top of Java-index,Java Essentials,Java Programming...
# 4
>Thanks. And I did search a lot before I posted this so I'm sorry if I missed something.If I had found stuff I wouldn't have posted.
gometro33a at 2007-7-14 22:42:21 > top of Java-index,Java Essentials,Java Programming...
# 5

May be you are using wrong key words.

Try "URLConnection" and/or "HttpURLConnection"

also you can try something like "Hot to use URLConnection" in google.

By the way the search in this site is quite crappy so if it does not work try in google.

I have seen so many times people (sometimes me) write codes on how to use URLConnection so you will find atleast one of them

LRMKa at 2007-7-14 22:42:21 > top of Java-index,Java Essentials,Java Programming...
# 6

> 1. When there are several fields named "example[]"

> how do I submit values?

If you have one parameter name that has different values (like in checkboxes), the servlet API (ServletRequest, I think) has a method called getParameterValues(paramName) that returns an array of String objects.

>

> 2. How do I wait until the POST is complete? The

> form uploads files. Is there something I can do

> (other than a simple timer) to make sure the files

> have completed before starting the next? Or should I

> just do one at a time?

You try uploading, and catch any eventual exceptions.

Note that there are several packages (Apache and Oreilly) that can help you with that task.

>

> 3. I'm confused about what happens after I submit the

> form. Basically...what do I do? Do I just make

> another URLConnection and what not? The page that I

> need to get is generated depending on what I upload.

HTTP uses a request-response paradigm. You send a request, and wait for a response. There are no special thing you need to do, except use try-catch-finally blocks and proceed to the next thing. If something goes wrong, you'll get an exception anyway, and the processing will stop. The important thing is how you handle those exceptions (retry, exit & send err message, etc..).

karma-9a at 2007-7-14 22:42:21 > top of Java-index,Java Essentials,Java Programming...