RESTful Java Web Services

Author: Jose Sandoval
3.0
This Year Stack Overflow 1
This Month Stack Overflow 1

Comments

by anonymous   2017-08-20

You should remember that:

  1. Only one method is executed for a single request. So it is impossible to execute two methods (or more) in single request;
  2. JAX-RS runtime decides which one method should be executed according to request header values sent to to the server.

JAX-RS runtime tries to match:

  • http method (GET,POST, ...) with proper annotation (@GET, @POST,...);

  • request path ('/api/something') with the proper @Path annotation;

  • http content-type header (link) with proper @Consumes annotation;

  • http accept header with propper @Produces annotation;

So (for example) @Produces annotation does not denote that annotated method produces something. It denotes that method will be executed when matching accept header will be contained in request.

If You need more information abou RestFull webservices i advice You to read these resources: