I am using json-lib-0.9.jar. in view.class i am getting inputstream from the request, setting into request and dorwarding request to Render.jsp, i am not able to understand how to fix this. could someone help me in in order to fix this issue. thanks in advance
View.class
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONObject;
private void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { {
if (request.getInputStream() != null) {
byte[] bytes = IOUtils.toByteArray(request.getInputStream());
String resString=new String(bytes, StandardCharsets.UTF_8);
JSONObject Json = JSONObject.fromString(resString);
request.setAttribute("META", Json.get("META"))
}
request.getRequestDispatcher("/jsp/Render.jsp").forward(request, response);
}
Render.jsp
<%@page import="net.sf.json.JSONObject" %>
<%
JSONObject docMeta = (JSONObject)request.getAttribute("META");%>
in this line its throwing
java.lang.ClassCastException
java.lang.ClassCastException: net.sf.json.JSONObject cannot be cast to net.sf.json.JSONObject
at org.apache.jsp.jsp.Render_jsp._jspService(PreviewLander_jsp.java:134)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:71)