Results 1 to 3 of 3
  1. #1
    kinabaloo is offline Member
    Join Date
    May 2008
    Posts
    6
    Rep Power
    0

    Default JTextPane with servlets

    I am using a JTextPane as a browser for simple servlet testing using a simple webserver on localhost and HttOutputStream.

    The textpane displays HTML ok except when returned by a servlet in which case I see the HTML markup. Connecting on an external browser like IE shows the servlet response correctly as HTML.

    The problem only happens when the servlet is called by a simple form; it works ok if called by hyperlink or the servlet address (+params) is typed into the address bar.

    Looking through the code that I wrote 5 years ago I see that i use a URLConnection to retrieve the data from the server from a hyperlink listener and then call setText() on the textpane. In the case of an HTML form, the server replies directly to the JTextPane which seems to forget it should display the returned text as HTML and not plain text. This worked before i migrated it to Java 1.6. There must be some tweek required, but what ?

    Any ideas ?
    Last edited by kinabaloo; 07-11-2008 at 06:35 AM. Reason: adding detail

  2. #2
    kinabaloo is offline Member
    Join Date
    May 2008
    Posts
    6
    Rep Power
    0

    Default

    Indeed, I found the contentType had been set to text/plain instaed of text/html

    How to avoid this ?

  3. #3
    kinabaloo is offline Member
    Join Date
    May 2008
    Posts
    6
    Rep Power
    0

    Default

    Well, I have managed to detect when it happens and quickly reset the page properly. It is barely noticeable so quite a good fix. But I would still like to know how to avoid it !

Similar Threads

  1. JTextPane Styles Example
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 06-27-2008, 07:48 PM
  2. [SOLVED] hyperlinks in JTextPane
    By olbion in forum New To Java
    Replies: 4
    Last Post: 05-05-2008, 03:28 AM
  3. how to show a html document on JTextPane
    By mary in forum Advanced Java
    Replies: 2
    Last Post: 08-02-2007, 01:40 PM
  4. how to insert tables into JTextPane
    By osval in forum AWT / Swing
    Replies: 1
    Last Post: 07-29-2007, 09:11 AM
  5. Transparent JTextPane
    By Ada in forum AWT / Swing
    Replies: 1
    Last Post: 05-31-2007, 09:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •