I have got a ResultSet after firing a query. Kindly let me know how i can convert it to a JSON output in JSP.
In the second stage, lets assume that we have got a JSON output like in this link > http://inknpost.com/eshopping/json.jsp
The above file is being accessed by a $.getJSON(); in another file.
Kindly let me know how can i display the “names” and the “departments” in different rows in a page.
Create a reuseable Javabean class which represents one row, a single entity.
Create a reuseable DAO class which maps the
ResultSetto a collection of those Javabeans the usual JDBC way.Create a servlet class which uses a JSON serializer/deserializer which is able to convert between an arbirary collection of Javabeans and a JSON String, such as Google Gson.
Invoke it by
http://localhost:8080/contextname/categories.json. No, there is no JSP involved. You should not be using JSP for output formats other than HTML.Finally, in jQuery, just access it the usual
$.getJSON()way.