In my Servlet a JSONObject is created with the value:
{'alerts':true}
When I am trying to print its value on JSP page using , it is printing the JSON object as String . It is printed as
"{'alerts':true}"
How do I print in JSON format rather than String?
In Servlet:
public JSONObject getAudioAlerts() {
JSONObject val = new JSONObject("{'alerts':true}");
return val;
}
In JSP:
<br><br><json:property name="audioAlerts" value="${myBean.audioAlerts"}" />;
<br> Expected output: {'alerts':true}
<br>Acutal output: "{'alerts':true}"
As per http://json-taglib.sourceforge.net/tutorial.html
By setting the value="..." attribute on the tag. <json:property/>
As per documentation your value is getting converted to Json String
so try to put your <json:property>
into <json:object></json:object>
or else you can parse your jSON string in javascript
var jsonObj = JSON.parse(audioAlerts)