Reputation: 109
What I am stuck on is how can I transfer very large JSON from servlet to html?
I have a servlet which does some processing and stores this in JSON. A new html page is made for the user (redirected), which requires the JSON to be passed somehow for Javascript to loop through and display in a presentable manner.
I am not 100% required to use JSON, just anything that can transfer 200ish rows of two distinct 'columns' of data; this of course needs to be easily accessible using Javascript at the other end.
Thank you
Upvotes: 0
Views: 1651
Reputation: 55897
If you are generating a new HTML page then you can simply embedd the data in a script tag within the page.
More usually we serve up an HTML page which loads a script, that script makes a request to the server, the request returning JSON which is then processed by the script, which will adjust the displayed DOM to show the data.
If you're using a framework such as Dojo then the code to do this is pretty easy, see examples such as this
Separating out the retrieval of the data from the specific page tends to work out well in the long-run: you then have a data service you can reuse in many pages.
Upvotes: 0
Reputation: 691685
If I understand correctly, you have
If this is correct, you need to store the JSON somewhere (in the session, for example), at the end of the first request, and then you have two choices :
<script>
tag, in Javascript variable initialization)Upvotes: 1