13

What is Resteasy? what is the difference between RESTEasy and JAX-RS? What is the difference between @PathParam and @QueryParam?

2
  • 1
    Your last question is a duplicate of this question. Commented Sep 18, 2012 at 7:55
  • 6
    Try to avoid asking two questions per “question” as it encourages incoherent answers; the @PathParam vs. @QueryParam question is really another question entirely. Commented Sep 18, 2012 at 12:59

4 Answers 4

22

According to its homepage RESTEasy is

... a fully certified and portable implementation of the JAX-RS specification.

So JAX-RS is a specification of how a library for implementing REST APIs in Java should look like and RESTEasy is one implementation of that specification.

This effectively means that any documentation on JAX-RS should apply 1:1 to RESTEasy as well.

Sign up to request clarification or add additional context in comments.

Comments

9

JAX-RS is a set of interfaces and classes without real implementation that belong to javax.ws.rs.* packages (they are part of Java SE 6, by Oracle).

RESTEasy as well as, for example, Jersey or Apache CXF, are open source implementations of that JAX-RS classes.

During compilation you need only JAX-RS. In runtime you need only one of that implementations.

Comments

7

Query parameters are extracted from the request URI query parameters, and are specified by using the javax.ws.rs.QueryParam annotation in the method parameter arguments.

Example:

@Path("smooth") @GET public Response smooth( @DefaultValue("2") @QueryParam("step") int step, @QueryParam("minm") boolean hasMin, @QueryParam("test") String test ) { ... } URL: http://domain:port/context/XXX/smooth?step=1&minm=true&test=value 

URI path parameters are extracted from the request URI, and the parameter names correspond to the URI path template variable names specified in the @Path class-level annotation. URI parameters are specified using the javax.ws.rs.PathParam annotation in the method parameter arguments

Example:

@Path("/{userName}") public class MyResourceBean { ... @GET public String printUserName(@PathParam("userName") String userId) { ... } } URL: http://domain:port/context/XXX/naveen 

Here, naveen takes as the userName(Path parameter)

Comments

1

Please also note that JAX-RS is only server side specification and RESTEasy has extended it to bring JAX-RS to the client side through the RESTEasy JAX-RS Client Framework.

Info on param, What is the difference between @PathParam and @QueryParam Some great points here regarding params, When to use @QueryParam vs @PathParam - Gareth's answer

1 Comment

FYI: JAX-RS 2.0 includes a client-side specification.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.