I'm trying to display HTML that I received from a server. However, the current code is only working for very few and simple HTML code (e.g. bad request pages).
This is a sample of very simple HTML that I cannot manage to display with my current code.
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.be/index.html?gfe_rd=cr&ei=uhoTU6CaDoSNOrHrgeAL">here</A>.
</BODY></HTML>
Here is my code which runs inside a JFrame.
JEditorPane ed1 = new JEditorPane("text/html", content);
add(ed1);
setVisible(true);
setSize(600,600);
setDefaultCloseOperation(EXIT_ON_CLOSE);
Note that content is just a string with every line of HTML concatenated to one another. Like so: content = "<HTML>.............</HTML>"
There might be more elegant solutions to fetching server responses and displaying them. But, I am restricted to the java.io and java.net packages.
<meta/>tag and give a try.