Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

URL connection and streams issue(earliest convenience)..  RSS feed

 
Vishu Neelavalli
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi frieinds,
i have a small trouble..while dealing with URLConnection..classes
I will first give u a very brief overview of my prog's functionality..
we all have so may forms on the WWW..some use the method "POST" and some use "GET" to send the data back to the server..
(the forms may be simple mail related stuff to search engines..i am interested in search engine forms..)
now..i we want to query a search engine ..
"using my java APplication"
scenario..
1.if the engine's form uses the method "GET".i can always observe the query string that gets displayed in the browser url box time to time and then employ the same to do my work.
2.(MAIN question********)
how to query the engine if it uses the method "POST"??
i know that we can get the input and output streams once the urlconnection is establised..but when i am writing to the outputstream..nothing is working...
kindly throw some light on this issue at your earliest convenience..
thanks,
Vishu
 
ARS Kumar
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Vishu
HttpUrlConnection class is best for your need. If you have a GET to do you can use the setRequestMethod(String) method of this class. For POST you have to construct the request string after properly URLEnconding the value parts of the string. Then use the setRequestMethod("POST") and open the OutputStream. You can then write your request to this stream.
I hope this will be of help. I have written applications which works in this way. Any other ideas are welcome.
-ARSKumar.
 
Vishu Neelavalli
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi kumar,
thanks for your time..
i have been trying it with URLConnection and also with HttpURLConnection...with partial to no success.
some times ..when i try running my application..coupla times frequently..
it says
<<br /> java.net.ProtocolException: Can't reset method: already connected<br /> >
..is it possible for us to talk online sometime soon!!
we can YAHOO ..my id is "neelavalli@yahoo.com"
we can MSN too..my id is "vishuonline@hotmail.com"
thanks,
Vishu
 
Vishu Neelavalli
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ,
I have a small doubt..
There is some javascript on the webpage that "posts" the form data to some cgi script. The javascript checks for some value in the form ..and it just returns "true" irrespective of wheter it find the required value or not..
My Doubt is..
1.Can we(if yes how??)encode this return value in the name/value pair query string we make while communication with CGI Scripts??
2.Does this return value play any role in communicating with the cgi script at all??
urgent please!!
thanks,
Vishu

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!