Can't form a simple POST or GET http request. No data returns.
Hi,
I'm having problems forming an http request in java.
Here's what I do:
I've got a simple php (java.php) file on my apache server, here's it's code:
Code :
<?php
$post_var = $_POST['post_var'];
if (!isset($post_var)) $post_var = $_GET['post_var'];
if ($post_var == 1) echo "works";
else echo $post_var . ": post_var";
?>
If I do this request:
Code :
http://warfarex.com/java.php?post_var=1
from browser, I get "works" output. The same if I send POST or GET request from a ActionScript 3 client.
But Java keeps on giving me this:
So, as you can see, it's the output of an "else" block.
And finally, here is the Java code I use to make these requests:
What's wrong with this code?
regards, Konstantin.
Re: Can't form a simple POST or GET http request. No data returns.
I've just found the problem myself.
It was the question mark in my request string.
This request:
Code :
String request = "post_var=1";
will work as a charm