Since I am planning to use Spring framework (Spring boot) and JSP goes well with Spring. Is it a good idea to use JSP for just HTML purpose? I am not going to use JSP for any other purpose other than displaying HTML.
The reasons I am considering using JSP are:
It works well well with Spring
I might have to user the server functionality if I plan do download flatfiles locally on the server somewhere.
Please let me know if I can clarify any questions. Thanks !
The reason I was considering JSP is because it goes well with Spring. As such, I don’t want to use any JSP functionality except one thing. I might want to download a huge JSON response on the server using some flat file logic etc, and I guess I would need some server side language to achieve that. I haven’t used JSP before though but the only reason I was thinking about using it was because of Spring.
I know PHP but I don’t think I would be able to use it on front end with Spring?
Maybe. But it would require a “bridge” and would probably be so much work it wouldn’t be worth the trouble. If you’re decided on using Spring then I think it would be more fruitful to go with Java even if you might have a bit of a learning curve to get over. Java is OOP, so if you know how to work with OOP the learning curve shouldn’t be that much of a problem for you.
I might want to download a huge JSON response on the server using some flat file logic etc, and I guess I would need some server side language to achieve that.
Thanks for the information. So, I am already using Ajax with jQuery. Basically, getting the response back from my Java webservice which is in the form of a JSON.
But here, I am wondering would it be possible to store the information in a flat file somewhere on the server so that the next time I won’t have to use the ajax call (which takes long time because of the webservice returning 20k records). Can this be done using Javascript? Please let me know if I am not understanding anything that you were trying to explain. Thanks !
You can query a flat file in AJAX if that’s what you’re wondering. It sounds like you’re having issues with the parsing and rendering of that file. 20k records is a lot. Is there no way to paginate that so you can build it in pieces? There are other ways of solving this problem, I would imagine. A lot of apps don’t even use server side rendering anymore.
Thanks again. Actually, I don’t even have a flat file right now. I just have a webservice which takes 4-5 mins (20k records) to return the results and figuring out other options.
In order to get the flat file, what should I do? I am wondering if I could generate a flat file with the JSON response that I am getting from web service or should I ask my database guy to generate a flat file. I believe fetching records from the file would come later on.
I think you misunderstood. You probably don’t need to be calling so many results at once at all. There’s no reason to generate a large file. That is what the backend is for.
I see. So, right now since my webservice is calling all 20k records ( because SQL is returning 20k records), when you say “That is what the backend is for” , did you mean that in this scenario, SQL should not be returning 20k records or should my web service be designed in some different manner? Thanks !
The query on the database should be limiting results in some way based on whatever criteria is relevant. This should speed up whatever you’re getting back considerably. You really only need to be getting like 100-500 results back max, no matter what you’re querying. The absolute largest single query returned to a UI I’ve ever written was 6000, but I only did that because it was already fast enough (under 50ms for the query) and wasn’t hit often.
If it’s taking 5minutes, even for 20k records, then some other issues are coming in to play… especially if it’s just a single table. If it’s a single table, it might be an easy fix of adding some indexes. If it’s multiple tables, then the fix will be a little harder but should be able to be accomplished.
Whatever it is, generating a flat file because the query is taking too long is a bandaid, not a solution.
I see. I might have to display 20k records to the user and have them download the results if they want to. When you say I should be getting “100-500” results max, are you referring something like pagination feature that I could use at the time of displaying the records on the table? But I guess in this scenario a user might have to do something multiple times to get 100-500 results back (For example, if I am displaying first 100 records, they would click next button on the table somewhere to get next set of 100 records and so on and so forth etc)
Do you think HTTP Caching mechanism could be an option?
You could auto load these across multiple requests. Load the first 100, then the next after that’s done. This is more or less how infinite scrolling works. The user probably isn’t going to need to instantly interact with everything all at once.