March 2018
Intermediate to advanced
310 pages
7h 10m
English
Let's create a simple Java EE application with a REST resource, which uses the GET method to serve the Hello world! message:
package org.packt.swarm;import javax.ws.rs.GET;import javax.ws.rs.Path;import javax.ws.rs.Produces;//1@Path("/")public class HelloWorldResource { //2 @GET //3 @Path("hello") @Produces({ "text/plain" }) public String hello() { return "Hello World!"; }}
In the listing above, we create a simple resource taking advantage of JAX-RS annotations; we define the main path for the whole class (1) and create the "hello" method, which is annotated with GET(2) and Path(3) annotations so that the "hello" method is executed when the HTML get method is invoked on a "/hello" path.
Furthermore, we have to define the ...
Read now
Unlock full access