include html content in jsp

Hi ,

I have the html data and need to include in the jsp .

eg :

String htmldata = " <html><body>testdata </body></html>";

how can i display this htmldata in the jsp . I mean I need this data in html format ( testdata ) and should not see all html tags in the explorer.

Suggest me if you know anything.

Thanks in advance.

- bregoty

[405 byte] By [bregotya] at [2007-11-27 9:48:05]
# 1
<% String htmldata="<html><body>testdata</body></html>";out.print(htmldata); %>
hetal_giria at 2007-7-13 0:16:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
create a seperate html file. Have a DIV tag in your jsp. Include your html file within DIV tag.<DIV ID="htmldata"><%@ include file="/myfile.html"%></DIV>
skp71a at 2007-7-13 0:16:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

I shouldn't use the path .. because path is always and restricted one. So i couldn't able to use the jsp:include tag to include html file.

The data is coming from the Event hander which retrieves from the databean.

I am getting the value like this ...

<table width=100% cellspacing=0 cellpadding=5>

<c:forEach items="${myBean}" var="myDB">

<tr height=10px> <td>

<c:out value="${myDB.htmldata}"/>

</td></tr>

</table>

I don't know whether it is parsing problem or some other thing.

Thanks,

bregoty

bregotya at 2007-7-13 0:16:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

You have the right idea, but you need to specify the escapeXml attribute on the c:out tag to be false. It defaults to true, and this means that when c:out encounters special characters it tries to display as-is rather, which is why you saw your HTML formatting. Set the escapeXml attribute to false and this should solve your problem.

<table width=100% cellspacing=0 cellpadding=5>

<c:forEach items="${myBean}" var="myDB">

<tr height=10px>

<td>

<c:out value="${myDB.htmldata}" escapeXml="false" />

</td>

</tr>

</table>

Zoan333a at 2007-7-13 0:16:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
Thanks a lot ! . It is working
bregotya at 2007-7-13 0:16:17 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...