user3069091
user3069091

Reputation: 71

Display String having html code in jsp

This is my string:-

String valueofString ="<p><b>Property Location</b> <br />With a stay at Sheraton Seattle Hotel, you'll be centrally located in Seattle, steps from 5th Avenue Theater and Washington State Convention Center. This 4-star" ;

Now I need to display this string in html but html elements is printing as it is by jsp output .

I tried like this:

<c:out value="${valueofString}" escapeXml="false"/>

but it is not work for me.

any help would be appreciated .

Thank you in advance.

Upvotes: 2

Views: 11652

Answers (2)

Kloe2378231
Kloe2378231

Reputation: 1434

This is not ideal, but you can use scriplet to do this: http://www.tutorialspoint.com/jsp/jsp_syntax.htm

<% 
    String valueofString ="<p><b>Property Location</b> <br />With a stay at ...";
    out.write(valueofString); 
%>

Something like this should be better:

Java:

String location ="Property Location";
String detail ="With a stay at ...";

JSP:

<p>
    <b><c:out value="${location}" /></b><br/>
    <c:out value="${detail}" />
</p>

Upvotes: 0

Vignesh Vino
Vignesh Vino

Reputation: 1238

Add <textarea> </textarea> to the begining and at the end of your string.

String valueofString ="<textarea><p><b>Property Location</b> <br />With a stay at Sheraton Seattle Hotel, you'll be centrally located in Seattle, steps from 5th Avenue Theater and Washington State Convention Center. This 4-star</textarea>" ;

Upvotes: 1

Related Questions