Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

setText doesn't display html!  RSS feed

 
Abdulmalik Malik
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all, I've been searching here as well as googling, but haven't found anything!

My problem is: I'm trying to JEditorPane as a simple web browser, but with setText rather than setPage method...

So, when I give setText simple html code like this, or even more as long as it is within the parentheses :


but when do this, in order to get a whole page, it doesn't work and doesn't display anything:

of course br is the BufferedReader object after connecting with any server using sockets
 
Rob Camick
Ranch Hand
Posts: 2754
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but when do this, in order to get a whole page, it doesn't work and doesn't display anything:


Sure it works. There is not difference, other than your HTML which must be causing the problem.

If you need further help then you need to create a SSCCE (Short, Self Contained, Compilable and Executable, Example Program), that demonstrates the incorrect behaviour.
 
Abdulmalik Malik
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Camick wrote:
but when do this, in order to get a whole page, it doesn't work and doesn't display anything:


Sure it works. There is not difference, other than your HTML which must be causing the problem.

If you need further help then you need to create a SSCCE (Short, Self Contained, Compilable and Executable, Example Program), that demonstrates the incorrect behaviour.


Thanks, but I tried with google, yahoo,...etc and no one worked!
I don't know where the problem is!
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay. So show us the simple code which doesn't display the HTML as you think it should. Your SSCCE should have a JEditorPane but no other irrelevant components, and the HTML should be hard-coded in the setup. Shouldn't be more than 50 lines really.
 
Abdulmalik Malik
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:Okay. So show us the simple code which doesn't display the HTML as you think it should. Your SSCCE should have a JEditorPane but no other irrelevant components, and the HTML should be hard-coded in the setup. Shouldn't be more than 50 lines really.

Thank you, here is the code, after being squeezed as much as I could squeeze it...

 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, use HttpURLConnection instead of trying to do HTTP by hand. Most HTTP servers these days are too sophisticated to accept anything as primitive as that.

Second, use a command-line telnet client to check out what the site returns before deciding thst JEditorPane isn't rendering it correctly. For example, for the address you used you're going to get back a whole mess of Javascript and little else.
 
Rob Camick
Ranch Hand
Posts: 2754
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Second, use a command-line telnet client to check out what the site returns before deciding thst JEditorPane isn't rendering it correctly


I was just going to suggest to add a JTextArea to your frame so you can display the text as returned from the server. This way you can see it side by side, the actual text and the renderer text.
 
Abdulmalik Malik
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll do what you said, but I shouldn't use HttpURLConnection, I have to do it by hand as required. So, please any suggestion?
 
Abdulmalik Malik
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I've figured out what I exactly need, I need to feed setText with as simple HTML code as possible, by filtering javascript and CSS tags out...

Because it displays simple pages with no such tags.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!