Pokušavam dobiti sadržaj stranice koja je iza forms autorizacijskog dijela;
public static String postWebString(String url ,ArrayList<NameValuePair> params,String username, String password) throws Exception
{
String result="";
URI URL=new URI(url);
HttpClient client = new DefaultHttpClient();
HttpPost request = new HttpPost(URL);
HttpContext webContext=new BasicHttpContext();
if(username!=null)
{
UsernamePasswordCredentials creds = new UsernamePasswordCredentials(username, password);
request.addHeader(new BasicScheme().authenticate(creds, request));
}
request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
HttpResponse httpResponse;
httpResponse = client.execute(request,webContext);
@SuppressWarnings("unused")
int responseCode = httpResponse.getStatusLine().getStatusCode();
//String message = httpResponse.getStatusLine().getReasonPhrase();
// Reading stream content - request from vecernji.hr login user
HttpEntity entity = httpResponse.getEntity();
InputStream instream = entity.getContent();
result = FileStreamHandler.convertStreamToString(instream);
return result;
}
Ali stvar ne prolazi... u biti ne prihvati autorizaciju .. povrat nije stranica koju sam tražio već ona koja se dobije ako se navedenom url.u pokušava pristupiti kao neautorizirani korisnik.
Pomoć molim...