i am trying to write a API using JSP/JSTL to generate JSON output but its not working in am not able to figure out the problem. Here i am getting problem when using C tag Library for reading the array.Here is the code:
<%@ page import="java.lang.*,java.io.*,java.util.*,java.sql.*"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<%@ taglib prefix="json" uri="http://www.atg.com/taglibs/json" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<sql:setDataSource var="snapshot" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/abc" user="root" password="xxx"/>
<sql:query dataSource="${snapshot}" var="result" sql="SELECT countries_name,countries_iso_code_2 FROM countries"/>
<json:object>
<json:object name="list">
<c:forEach var="row" items="${result.rows}">
<json:object items="countries">
<json:property name="Country" value="${row.countries_name}"/>
<json:property name="iso" value="${row.countries_iso_code_2}"/>
</json:object>
</c:forEach>
</json:object>
</json:object>
The Exception i am getting is as
org.apache.jasper.JasperException: java.lang.ClassNotFoundException: org.apache.jsp.ws.indexajson_jsp
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:178)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:370)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
Please help me to rectify the problem. Thanks.
I just have solved it. i just removed C Tag Library changed json generating code as
and it works. i got the problem was my array syntax.