package test.com; import java.util.Random; import javax.servlet.http.HttpServlet; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; @Path("/app") public class Test extends HttpServlet { private static final long serialVersionUID = 1L; private static int num; @GET @Produces(MediaType.TEXT_HTML) public String test() { return "<b>Hello, World!</b>" + new Random().nextLong() + "<br>" + num; } @Produces(MediaType.TEXT_HTML) @Path("/set") @GET public String setnum(@QueryParam("num") int set) { num = set; return "OK:" + String.valueOf(num); } }