This post is very similar with the Spark Java example with JQuery Ajax except here we would use POST method for the Ajax call. Like the other example, we would get input of two numbers from the web page UI, make a ajax POST call to server with those numbers, the numbers get added at the server and returned result and finally display the result to web page UI without refreshing the page.
Spark is a relatively new, simple and lightweight framework written in Java which helps developers to rapidly create web services in minimal effort. It comes with embedded Jetty web server which hosts the web services. The syntax of declaring web services are very simple, quite similar with Node.js, which makes Node.js developers learn SparkJava quickly. Spark framework only works on Java 8 as it is built on Java 8’s Lambda philosophy.