How to connect backend

Something that's been bothering me for a while now is, Just how do you connect the back end program with the front end of a website?

I built a search engine as part of a school project with friends. It was all Java console. As Java console is definitely not user friendly, I wanted to adapt the project into a website. However, how does any part of user input call any of my java functions? Also, how should my program output data to the frontend for the user to see?