Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-11-2008, 02:05 AM
Member
 
Join Date: May 2008
Posts: 6
kinabaloo is on a distinguished road
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 08:35 AM. Reason: adding detail
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-11-2008, 04:00 AM
Member
 
Join Date: May 2008
Posts: 6
kinabaloo is on a distinguished road
Indeed, I found the contentType had been set to text/plain instaed of text/html

How to avoid this ?
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-11-2008, 08:32 AM
Member
 
Join Date: May 2008
Posts: 6
kinabaloo is on a distinguished road
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 !
__________________
Kinabaloo

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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


All times are GMT +3. The time now is 04:41 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org