Questions tagged [jax-rs]

JAX-RS: Java API for RESTful Web Services. It is an API that provides support in creating web services according to the REST architectural style.

JAX-RS: API for RESTful Web Services is an API that provides support in creating web services according to the architectural style. JAX-RS uses annotations, introduced in Java SE 5, to simplify the development and deployment of web service clients and endpoints. From version 1.1 on, JAX-RS is an official part of Java EE.

The home for the JAX-RS JSRs is on Java.net.

JAX-RS is implemented by the following frameworks:

Resources:

7676 questions
507
votes
2 answers

How to implement REST token-based authentication with JAX-RS and Jersey

I'm looking for a way to enable token-based authentication in Jersey. I am trying not to use any particular framework. Is that possible? My plan is: A user signs up for my web service, my web service generates a token, sends it to the client, and…
DevOps85
  • 6,473
  • 6
  • 23
  • 42
349
votes
18 answers

When to use @QueryParam vs @PathParam

I am not asking the question that is already asked here: What is the difference between @PathParam and @QueryParam This is a "best practices" or convention question. When would you use @PathParam vs @QueryParam. What I can think of that the decision…
Blessed Geek
  • 21,058
  • 23
  • 106
  • 176
338
votes
4 answers

REST response code for invalid data

What response code should be passed to client in case of following scenarios? Invalid data passed while user registration like wrong email format User name/ Email is already exists I chose 403. I also found following that I feel can be…
Amit Patel
  • 15,609
  • 18
  • 68
  • 106
281
votes
14 answers

JAX-RS — How to return JSON and HTTP status code together?

I'm writing a REST web app (NetBeans 6.9, JAX-RS, TopLink Essentials) and trying to return JSON and HTTP status code. I have code ready and working that returns JSON when the HTTP GET method is called from the client.…
Meow
  • 18,371
  • 52
  • 136
  • 180
227
votes
11 answers

JAX-RS / Jersey how to customize error handling?

I'm learning JAX-RS (aka, JSR-311) using Jersey. I've successfuly created a Root Resource and am playing around with parameters: @Path("/hello") public class HelloWorldResource { @GET @Produces("text/html") public String get( …
Mark Renouf
  • 30,697
  • 19
  • 94
  • 123
226
votes
17 answers

Java 8 LocalDate Jackson format

For java.util.Date when I do @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd/MM/yyyy") private Date dateOfBirth; then in JSON request when I send { {"dateOfBirth":"01/01/2000"} } it works. How should I do this for Java 8's…
JAB
  • 3,546
  • 9
  • 36
  • 39
201
votes
3 answers

URL matrix parameters vs. query parameters

I'm wondering whether to use matrix or query parameters in my URLs. I found an older discussion to that topic not satisfying. Examples URL with query params: http://some.where/thing?paramA=1¶mB=6542 URL with matrix params:…
deamon
  • 89,107
  • 111
  • 320
  • 448
198
votes
4 answers

Difference between JAX-RS and Spring Rest

I confused with the difference between JAX-RS (well, maybe should use Jersey to do comparison since JAX-RS is just spec) and Spring for Restful services. I tried to search for more information online and it become more confusing. My company is using…
hades
  • 4,294
  • 9
  • 46
  • 71
171
votes
14 answers

Can not deserialize instance of java.util.ArrayList out of START_OBJECT token

I'm trying to POST a List of custom objects. My JSON in request body is this: { "collection": [ { "name": "Test order1", "detail": "ahk ks" }, { "name": "Test order2", …
isah
  • 5,221
  • 3
  • 26
  • 36
141
votes
3 answers

REST API DESIGN - Getting a resource through REST with different parameters but same url pattern

I have a question related to REST URL design. I found some relevant posts here Different RESTful representations of the same resource and here RESTful url to GET resource by different fields but the responses are not quite clear on what the best…
shahshi15
  • 2,772
  • 2
  • 20
  • 24
136
votes
3 answers

What does Provider in JAX-RS mean?

Could anyone explain to me what a JAX-RS Provider is and what ‘@Provider’ annotation does? I have been reading documentation but I cant get it. If there are resource classes that service the incoming requests, what do Providers do? How are they…
Artem Moskalev
  • 5,748
  • 11
  • 36
  • 55
126
votes
1 answer

How to access parameters in a RESTful POST method

My POST method looks like this: @POST @Consumes({"application/json"}) @Path("create/") public void create(String param1, String param2){ System.out.println("param1 = " + param1); System.out.println("param2 = " + param2); } When I create a…
Klaasvaak
  • 5,634
  • 15
  • 45
  • 68
115
votes
10 answers

Input and Output binary streams using JERSEY?

I'm using Jersey to implement a RESTful API that is primarily retrieve and serve JSON encoded data. But I have some situations where I need to accomplish the following: Export downloadable documents, such as PDF, XLS, ZIP, or other binary…
Tauren
  • 26,795
  • 42
  • 131
  • 167
111
votes
4 answers

What is the difference between @PathParam and @QueryParam

I am newbie in RESTful jersey. I would like to ask what is the different between @PathParam and @QueryParam in jersey?
Mellon
  • 37,586
  • 78
  • 186
  • 264
107
votes
5 answers

What difference between Jersey vs jax-rs

I really cant understand what really is jersey.. What I know is that Jax-RS is an API for building REST web services, and jersey? I got some information and all say the same: "jersey is an implementation of Jax-RS". But what it means? If jax-rs is…
user1851366
  • 256
  • 6
  • 20
  • 41
1
2 3
99 100