import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
@Path("hello")
public class HelloWorldResource {
    private String message = "Hello StackOverflow!";
    @GET
    @Produces("text/plain")
    public String getHello() {
        return message;
    }
    @DELETE
    public Response deleteMessage() {
        message = null;
        return Response.noContent().build();
    }
}
Consume it with curl:
$ curl http://localhost/hello
Hello StackOverflow!
$ curl -X "DELETE" http://localhost/hello
$ curl http://localhost/hello
null