My JSP, is being passed an JSONObject in the context, on which it needs to do some processing like creating tables, etc.
But when I try to access the member of this object, it gives the following error –
(the name of one of the keys in this object is ok)
Servlet.service() for servlet jsp threw exception { javax.servlet.jsp.el.ELException:
Unable to find a value for "ok" in object of class "org.json.JSONObject" using operator "."
JSP Code accessing it looks like this –
<%@ taglib uri=”http://java.sun.com/jsp/jstl/core” prefix=”c”%>
<c:if test="${serviceOutput.ok}">
<c:if test="${serviceOutput.ret.proposalCount} > 0">
.....
Can anyone please suggest how I can resolve this and successfully access all the members of this object?
EL only understands Javabeans and
Maps. You need to let a preprocessing servlet convert each item of theJSONObjectto a fullworthy Javabean which has getter methods which can be used in EL, or to aMap.Here’s an example which converts it to a
Map:This way EL expressions like
${serviceMap.ok}will work.