Results 1 to 13 of 13
Thread: HttpURLconnection POST request
- 05-20-2012, 11:09 AM #1
Member
- Join Date
- May 2012
- Posts
- 12
- Rep Power
- 0
HttpURLconnection POST request
i want to send a request with post data
i tried looking it up for myself, but this page has alot of missing information
HTTP POST Basics
when i compiled it the compiler didnt know what connector.open was or httprequest was etcLast edited by chopficaro; 05-20-2012 at 11:17 AM.
- 05-20-2012, 12:47 PM #2
Re: HttpURLconnection POST request
Please post the full text of any error messages.the compiler didnt know
Did you spell the class names and method names correctly?
Did you have the needed import statements?If you don't understand my response, don't ignore it, ask a question.
- 05-20-2012, 01:14 PM #3
Member
- Join Date
- May 2012
- Posts
- 12
- Rep Power
- 0
Re: HttpURLconnection POST request
i copied and pasted it exactly so everything was spelled correctly, but then i started messing with it because it wasnt working, i replaced HttpConnection with HttpURLConnection and stuff
maybe i dont have the "connector" import statement, but i cant find any class called connector
it looks like connector is an object tho and they dont show the instanciation of the class
they dont show the instanciation of alot of classes actually...
i just want to make a POST request this shouldnt be so hard
InputScreen.java:302: cannot find symbol
symbol : variable Connector
location: class InputScreen
conn = (HttpURLConnection) Connector.open( check
URL );
- 05-20-2012, 01:17 PM #4
Re: HttpURLconnection POST request
Where is the class: Connector defined?
If you don't understand my response, don't ignore it, ask a question.
-
Re: HttpURLconnection POST request
Locked (temporarily if need be) due to spam attack.
- 05-20-2012, 09:56 PM #6
Member
- Join Date
- May 2012
- Posts
- 12
- Rep Power
- 0
http request with POST data
i want to send a request with post data
i tried looking it up for myself, but this page has alot of missing information
HTTP POST Basics
when i compiled it the compiler didnt know what connector.open was or httprequest was etc
i copied and pasted it exactly so everything was spelled correctly, but then i started messing with it because it wasnt working, i replaced HttpConnection with HttpURLConnection and stuff
maybe i dont have the "connector" import statement, but i cant find any class called connector
it looks like connector is an object tho and they dont show the instanciation of the class
they dont show the instanciation of alot of classes actually...
i do not know where the class connector is defined
i just want to make a POST request this shouldnt be so hard
InputScreen.java:302: cannot find symbol
symbol : variable Connector
location: class InputScreen
conn = (HttpURLConnection) Connector.open( check
URL );
Edit: sorry for the re post but someone locked the other thread, probably because im new and they think im a spam bot, but nope im just a guy who wants to make a post requestLast edited by chopficaro; 05-20-2012 at 09:58 PM.
- 05-20-2012, 10:53 PM #7
Re: HttpURLconnection POST request
No, nobody thought you were a spambot. But there were a series of spambot posts to your thread, so the thread was locked temporarily.
I've merged your new post here.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 05-20-2012, 11:10 PM #8
Re: HttpURLconnection POST request
Where is the class: Connector defined?
If you don't understand my response, don't ignore it, ask a question.
- 05-21-2012, 12:30 AM #9
Member
- Join Date
- May 2012
- Posts
- 12
- Rep Power
- 0
Re: HttpURLconnection POST request
i dont know where the class connector is defined
thats what ive been trying to say
i just saw the code on the link i posted, but i cant find connector class on the oracle site, so i cant type in the import statement
why did they not show the instanciation or import in the guide i posted idk
- 05-21-2012, 01:15 AM #10
Member
- Join Date
- May 2012
- Posts
- 12
- Rep Power
- 0
Re: HttpURLconnection POST request
i would show u my code but it is so messed up from dumb stuff ive done to try to fix it
can someone just explain the missing information to me?
why is it so hard to make a post request????
- 05-21-2012, 01:32 AM #11
Re: HttpURLconnection POST request
Perhaps you should start with a new version that doesn't copy code that's missing parts.
Try using the URL openConnection() method. Print out the value it returns.Last edited by Norm; 05-21-2012 at 01:51 AM.
If you don't understand my response, don't ignore it, ask a question.
- 05-21-2012, 02:06 AM #12
Member
- Join Date
- May 2012
- Posts
- 12
- Rep Power
- 0
Re: HttpURLconnection POST request
ok i looked up url openConnection(), it said to make a post request do this
but the last few lines dont make any sense. how do i get the content returned by the post request as a string?Java Code:String urlParameters = "param1=a¶m2=b¶m3=c"; String request = "http://example.com/index.php"; URL url = new URL(request); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setDoOutput(true); connection.setDoInput(true); connection.setInstanceFollowRedirects(false); connection.setRequestMethod("POST"); connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); connection.setRequestProperty("charset", "utf-8"); connection.setRequestProperty("Content-Length", "" + Integer.toString(urlParameters.getBytes().length)); connection.setUseCaches (false); DataOutputStream wr = new DataOutputStream(connection.getOutputStream ()); wr.writeBytes(urlParameters); wr.flush(); wr.close(); connection.disconnect();
- 05-21-2012, 02:10 AM #13
Similar Threads
-
HTTP POST Request (HttpURLConnection)
By Dude in forum NetworkingReplies: 17Last Post: 07-15-2011, 11:11 PM -
POST request using HttpUrlConnection
By turk in forum NetworkingReplies: 3Last Post: 07-06-2011, 04:36 PM -
POST request using HttpUrlConnection
By turk in forum NetworkingReplies: 2Last Post: 07-06-2011, 04:29 PM -
how to POST data to server using HttpURLConnection ??
By dhana in forum NetworkingReplies: 4Last Post: 10-15-2008, 01:59 PM -
First post as per request
By happyknappy in forum IntroductionsReplies: 3Last Post: 07-30-2008, 01:33 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks