post form data

there is a poll form on the web that posts data to an ASP page
I created a html file localy and i am able to post form data just like this

<form name="frm" method="post" action="the url">
    <input type="hidden" name="voteChoice" value="498">
    <input type="hidden" name="PID" value="108">
    <input type="hidden" name="TID" value="7714">
    <input type="hidden" name="FID" value="33">
    <input type="hidden" name="PN" value="0">
    <input type="hidden" name="TPN" value="1">
    <input type="submit" name="Submit" value="Submit">

when I want to do this via java with the below code its not successfull to update the poll. i dont know why ?

import java.util.*;

public class PostForm {
    public static void main(String[] args) throws Exception {
        URL url = new URL("the url");
        String argString = "voteChoice=498&PID=108&TID=7714&FID=33&PN=0&TPN=1";
        argString = "voteChoice=498&PID=108&TID=7714&FID=33&PN=0&TPN=1";
        URLConnection con = url.openConnection();
        con.setRequestProperty("Referer", "");
        con.setRequestProperty("User-Agent", "Mozilla/5.0");
        con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
        // Write the arguments as post data
        OutputStream out = con.getOutputStream();
        // Read the response
        InputStream is = con.getInputStream();
        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        String line = null;
        while((line = br.readLine()) != null) {
LVL 14
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

It's not really related to a <form> Check

hoomanvAuthor Commented:
im doing this already
my problem is somthing else
what is the difference between the html file and my java app
when a browser parses the html it would do just somthing like i do
but somthing in the server side i guess prevents the java app
after sobmitting that poll server will send me the updated poll
if i use the html version, it updates, but using java it just send me the current poll
should i explain more ? (sorry for my bad english)
>>im doing this already

Doesn't really look like it. What's in 'argString'?
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

hoomanvAuthor Commented:
i made the previous question because i though the ASP page rejects unknown submitters and that was why i changed the referer and user-aganet. but nothing helpd. as a guess is there anything else is submitted by the browser that im forgetting in my java app. for example cookies ??
hoomanvAuthor Commented:
the argString is the encoded version of all the arguments that have to be sent. any GET and POST request should first convert the argument list to somthing like this
Quite possibly - cookies are often required, but the request has also to be formed correctly. You should probably inspect what your browser is sending using a proxy such as Eclipse+Solex
hoomanvAuthor Commented:
you mean i need to install a proxy server and make my request through it to find out what is going on exactly ?
before that i first clear my cookies and test again, then i use another browser and test again
hoomanvAuthor Commented:
and i forgot to say the request is correct 99%, because I'll get to the poll page by providing varibales PID,TID,FID,... (these are form inputs),  but the only failure is that the "voteChoice"="498" seems not working correctly in java but it does in borwser
hoomanvAuthor Commented:
ok i got good results
i was unable to post the form using MS IE, simply because I have already signed in to that site using FireFox, and there are 4 cookies set by the site in my borwser. so only I can use FireFox to post the form. so i ask another question. how can i login to that site using java and permit it to set cookies, how can i use the currently set cookies to comunicate with that site to authorize my java app and post the form. generally how exactly the server requests the cookie from browser ?
>>you mean i need to install a proxy server and make my request through it to find out what is going on exactly ?

That's really the only way to find out precisely what happens in your browser
You need to hit a main page first and collect the cookies. You'll find all this much easier with a proper http library such as Jakarta Commons HttpClient

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hoomanvAuthor Commented:
yes thats it.

HttpClient supports automatic management of cookies, including allowing the server to set cookies and automatically return them to the server when required. It is also possible to manually set cookies to be sent to the server.

A * 20 points for a name.

though you helped me today, yesterday i just consume 125 points because i was a newbie and unfamiliar with grading system. that day i asked about non-blocking IO and you refered me to java.util.concurrent but that did not work i found that only chanels have the ability to be interrupted not traditional io, if im wrong tell me, but my problem is still alive. the availeble() method does not work either and the call to this method also blocks on foregoing circumstances. i cant get the inputstream out of block at all. do you have any suggestions ?
>>you refered me to java.util.concurrent but that did not work

Please remind me of the url of that Q
hoomanvAuthor Commented:

if i grade you in this thread ? would be able to post here again ?
I'll post there again irrespective of what happens here
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.