I am trying to use jsp to generate json. The problem is, there is generated a HTML which contains my json. The point not to generate html.
Java7, JBoss4 and jsf probably 2.5.
Thanks
CodePudding user response:
The problem is not on the JSP side. Your JSP returns a valid Json, and the browser (Chrome) adds the HTML.
For example, with a JSP containing this source:
<%@ page contentType = "application/json" %>
{"test": {"value": "1", "value2" : "2", "value3" : "3"}}
CodePudding user response:
Maybe you should set the content type on your JSP:
<%@ page contentType = "application/json" %>
but the HTML is produced by your code so you should remove that part.