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:

7360 questions
488
votes
2 answers

Best practice for 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,265
  • 6
  • 20
  • 39
308
votes
15 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
  • 19,240
  • 21
  • 96
  • 165
291
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
  • 14,288
  • 17
  • 61
  • 100
260
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
  • 16,125
  • 50
  • 122
  • 176
221
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
  • 29,573
  • 19
  • 89
  • 120
183
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
  • 78,414
  • 98
  • 279
  • 415
175
votes
16 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,008
  • 8
  • 34
  • 38
163
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
  • 3,200
  • 5
  • 28
  • 56
148
votes
13 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
  • 4,725
  • 2
  • 19
  • 32
123
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,430
  • 12
  • 43
  • 67
119
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,488
  • 11
  • 34
  • 52
112
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
  • 25,387
  • 37
  • 126
  • 165
102
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
  • 33,620
  • 73
  • 177
  • 259
100
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,332
  • 2
  • 17
  • 23
98
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
  • 1,056
  • 3
  • 17
  • 34
1
2 3
99 100