• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

setText doesn't display html!

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Marshal
Posts: 28424
102
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...

 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic