I’d like to create a simple Java web server that displays the text ‘Hello, user!’ in the browser whenever I navigate to localhost:8080 in a web browser window. I also want it to display the text “Hi!” whenever I navigate to localhost:8080/hi. Is it possible to write a Java server that does this concisely? (Specifically, I’m trying to find out how to create a simple RPC mechanism in Java that allows Java functions to be invoked from other programming languages.)
I’d like to create a simple Java web server that displays the text ‘Hello,
Share
If you’re trying to create RESTful web services in Java, then JAXRS is the way to go.
You don’t need to develop an http server, that is already written and there are many choices of well-tested and highly scalable http servers in Java. To develop RESTful web services with JAXRS, you annotate classes and methods in them with annotations that describe which http method, content type, and parts of the URL path they will respond to.
I happen to be familiar with Netbeans, and I could write what you describe and have it running in a matter of minutes.
References: http://en.wikipedia.org/wiki/Java_API_for_RESTful_Web_Services and http://docs.oracle.com/javaee/6/tutorial/doc/giepu.html