0

I am crating a json array of dynamic length in my BO class and passing that array to the controller.from controller I have send that array to the jsp successfully using expression language.now I am getting an exception on my for each loop end value.the end value is the length of the json array. I am using ${array.length ()} this.but getting number format exception.

2
  • It would help if we could look at an example JSON object that needs to be parsed, so we can provide a more detailed answer. Could you please edit your question to include this? Commented May 18, 2015 at 14:21
  • @ShotgunNinja [{"state":"WEST BENGAL","so/bo":"Ajodhya B.O","district":"Bankura","taluk":"Vishnupur"},{"state":"WEST BENGAL","so/bo":"Amral B.O","district":"Bankura","taluk":"Bishnupur"}] This is my json array I'm passing to the jsp using ModelAndView.addObject("name",JSONObject) maibnly I am Facing problem in Iterating the JsonArray using for each loop of jstl core. If You have any solution please help me. Commented May 19, 2015 at 4:35

1 Answer 1

1

I Got the Solution:

'<table>
<tr>
<% int lengthOfArray =(Integer)request.getAttribute("length");
%>
</tr>
    <c:forEach var="i" begin="0" end="<%=lengthOfArray-1 %>">
    <tr>
  <td>
  <c:out value="${array.getJSONObject(i).getString('soBoOrZipcode')}"/>
  </td>
  <td>
  <c:out value="${array.getJSONObject(i).getString('taluk')}"/>
  </td>
  <td>
    <c:out value="${array.getJSONObject(i).getString('district')}"/>
  </td> 
  <td>
    <c:out value="${array.getJSONObject(i).getString('state')}"/>
  </td>
  </tr>
</c:forEach> 
</table>'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.