Reputation: 135
I am try to use an external website to get data but what I seem to be getting is the whole Html source code for the website. Infact it does not process the parameters i pass to it. The website is http://www.siirretytnumerot.fi/ and if I add the QueryServerlet to the end of the link I just get a short structure of the source code for the link without any result. I have also tried using both HttpPost and Get still same out. Please can someone kindly tell me is the problem is that the website cannot be used for resources purpose? Please I would take any advice or suggestions. The code I am using is this. And note I have a try and catch clause surround this code.
HttpClient client = new DefaultHttpClient();
String postURL = "http://www.siirretytnumerot.fi/";//if I add QueryServlet to the end it just gives a response with the html structure
BufferedReader in=null;
String data=null;
HttpPost post = new HttpPost(postURL);
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("PREFIX", "044"));
params.add(new BasicNameValuePair("NUMBER", "9782231"));
params.add(new BasicNameValuePair("LANGUAGE", "English"));
params.add(new BasicNameValuePair("Submit", "Search"));
UrlEncodedFormEntity ent = new UrlEncodedFormEntity(params,HTTP.UTF_8);
post.setEntity(ent);
HttpResponse responsePOST = client.execute(post);
in=new BufferedReader(new InputStreamReader(responsePOST.getEntity().getContent()));
StringBuffer sb=new StringBuffer("");
String l="";
String nl=System.getProperty("line.separator");
while((l=in.readLine())!=null){
sb.append(l+nl);
}
in.close();
data=sb.toString();
list.add(data);
datalist=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,list);
ml.setAdapter(datalist);
This is output I get from response
<img src="QueryServlet?ID=457016727131196340&STRING=QIHfqzk16uj6adStbdzyaqMjYwaokhP1Zq1Tlz%2BjL4YQ7tRne4RdxwCcvcJKiZWvvsTXcpqHxcDplE9LVExKGg==" />
Upvotes: 1
Views: 137
Reputation: 59168
Try like this:
String postURL = "http://www.siirretytnumerot.fi/QueryServerlet";
...
params.add(new BasicNameValuePair("Submit2", "Clear"));
...
UrlEncodedFormEntity ent = new UrlEncodedFormEntity(params);
Upvotes: 2