I'm familiar with a variety of programming languages, my best being java. I'm in the process of learning javascript, and there are a ton of resources out there for that. But I'm struggling to find resources on how to connect to java code which would then return results.
As an example, I can write java programs to pull data from a database and manipulate/aggregate it. Say I want to build a page which gives the users a few options on how to pull/aggregate the data. I can easily write some java code to do this, and with some googling I should be able to easily build a web page which gives the users some options. What I don't know how to do is how to have javascript execute the java code (passing arguments) and get the data to display from java. From reading it seems like the best format for passing the data would be JSON and I understand the basics of that but my issue is figuring out how to call a java program from javascript in real time and how to pass the JSON back to javascript to use on the page.
I realize it's a really general question, I'm not looking for someone to explain this but more links to references that would help me get started with this. Thanks!