-
Bug
-
Resolution: Fixed
-
P4
-
1.4.0
-
tiger
-
x86
-
windows_nt, windows_2000
Name: jl125535 Date: 05/31/2002
FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
FULL OPERATING SYSTEM VERSION :
Windows NT 4.0 SP6
EXTRA RELEVANT SYSTEM CONFIGURATION :
Dell Inspiron 7500 laptop. 384MB RAM. PIII 450MHz.
A DESCRIPTION OF THE PROBLEM :
When the tag <meta http-equiv=Content-Type
content=text/html> is included in the HEAD section of an
HTML document passed as a string to jeditorpane.setText
(String) JEditorPane fails to render the body section
entirely.
It appears the JEditorPane class fails to properly output the body (and perhaps
other sections?) when a META tag that specifies "http-equiv=Content-Type" is
used. Other META tags do not necessarily cause the problem.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Simply run the code provided.
EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected:
The test program should display the following:
[jeditorpane.getText() produces:]
<html>
<head>
</head>
<body>
<p>
Hello
</p>
</body>
</html>
Actual:
The test program displays the following:
[jeditorpane.getText() produces:]
<html>
<head>
</head>
<body>
<p>
</p>
</body>
</html>
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
public class TestJEditorPane {
void test (String test_content) {
JEditorPane jeditorpane = new JEditorPane();
jeditorpane.setContentType ( "text/html" );
jeditorpane.setText ( test_content );
System.out.println ( "[This is the string used in setText(String):]" );
System.out.println ( test_content );
System.out.println ();
System.out.println ( "[jeditorpane.getText() produces:]" );
System.out.println ( jeditorpane.getText() );
}
TestJEditorPane () {
/*
* Test a very simple HTML String.
*/
test ( "<HTML><HEAD></HEAD><BODY> Hello </BODY></HTML>" );
System.out.println ( "-----------------------------------------------");
/*
* Try the same string but insert a META tag that specifies
* http-equiv=Content-Type in the HEAD section.
*/
test ( "<HTML><HEAD><META http-equiv=\"Content-Type\" "
+ "content=\"text/html\">"
+ "</HEAD><BODY><P>Hello</P></BODY></HTML>" );
/*
* Notice after calling test(String) this second time the word
* "Hello" is not in the String produced by getText() in
* JEditorPane. This appears to be a bug.
*/
}
public static void main (String args[]) {
/* call default constructor */
TestJEditorPane t = new TestJEditorPane ();
}
} // end class
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
I can parse the HTML String and remove everything in the
HEAD section before calling JEditorPane.setText(String).
This is somewhat cumbersome because in some cases we are
working with a high volume of files and very frequently
refreshing. This does have an impact on performance.
(Review ID: 138737)
======================================================================
- duplicates
-
JDK-4695761 JEditorPane setText fails with a meta content-type
-
- Closed
-
- relates to
-
JDK-6724188 JEditorPane does not render HTML BODY if a META tag is included in HEAD
-
- Open
-