Hell Guys!
I have a goal to view the response from a HttpClient response in a JEditopane.
If I just do like this in a Jeditorpane:
setPage("http://www.nu")
...it works like a dream.
But my app sends a form and I would like to view the result in a JEditorpane
something like:
HttpPost httppost = new HttpPost( form.getAction() );
httppost.setEntity(entity);
HttpResponse httpResponse = httpclient.execute(httppost);
InputStreamReader inputStreamReader = new
InputStreamReader(httpResponse.getEntity().getContent());
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
StringBuffer lines = new StringBuffer( );
String line = "";
while ( (line = bufferedReader.readLine()) != null)
{
lines.append(line);
lines.append('\n');
}
String html = lines.toString();
In subclass of JEditorpane I have tried like:
setText( html );
...and also read from the InputStream.
try
{
InputStreamReader inputStreamReader = aObjectOfMy.getInputStreamReader();
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
synchronized(inputStreamReader)
{
read(bufferedReader, null);
}
}
catch (IOException e)
{
e.printStackTrace();
setText( "url: " + formResponse.getUrl() + "\n"+ e.getMessage() );
}
But I never get it to be view like it should be, sometime noting at all is
viewed and some times I get no images.
I think you could try it agains any form out there. I have never managed to
view any response properly.
How ever I would like to say that I think the error is my way to use
JEditorpane, rather then something is wrong in HttpClient API.
So if any one have any suggestions how to get the result viewed nice in a
editorpane, please let me know.
Best regards
Fredrik