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
52
votes
3 answers

How to set response header in JAX-RS so that user sees download popup for Excel?

I wrote code that generate Excel file using REST JAX-RS and I confirmed that the generated Excel file is in GlassFish server directory. But my goal is when user click on the button (which generate Excel .xls), I want download popup to show up asking…
Meow
  • 18,371
  • 52
  • 136
  • 180
52
votes
8 answers

Custom ObjectMapper with Jersey 2.2 and Jackson 2.1

I am struggling with a REST application with Grizzly, Jersey and Jackson, because Jersey ignores my custom ObjectMapper. POM dependencies: org.glassfish.jersey.containers
svenwltr
  • 17,002
  • 12
  • 56
  • 68
51
votes
3 answers

Servlet vs RESTful

Today I read about Restful services. Basically what I understand that is Restful webservices will work on HTTP request methods rather than normal webservice will work on SOAP request. What is the need for Restful services as normal servlet can also…
Dilip
  • 929
  • 3
  • 13
  • 32
50
votes
7 answers

JAX-RS Frameworks

I've been doing some work with the JAX-RS reference implementation (Jersey). I know of at least two other frameworks (Restlet & Apache CXF). My question is: Has anyone done some comparison between those frameworks and if so, which framework would…
Shimi Bandiel
  • 5,773
  • 3
  • 40
  • 49
50
votes
3 answers

Best way to handle JAX-RS REST API URI versioning

I did my search first in stackoverflow & I was not able to find out any answers related to my question. All I can find was questions related to REST uri design. My question in on the backend side. Suppose we have two different version of REST…
Deepesh M
  • 833
  • 1
  • 10
  • 18
49
votes
4 answers

How does one intercept a request during the Jersey lifecycle?

I've used Jersey for the better part of a year now and have just stumbled upon a problem to which I can't find the answer: how do you intercept (or hook into) the Jersey request lifecycle? Ideally, I'd be able to perform some custom…
cww
  • 1,128
  • 1
  • 8
  • 15
49
votes
3 answers

Logging request and response in one place with JAX-RS

I have a RESTEasy web server with lot of methods. I want implement logback to track all requests and responses, but I don't want add log.info() to every methods. Maybe there's way to catch requests and responses in one place and log it. Maybe…
Edgaras Karka
  • 7,400
  • 15
  • 61
  • 115
47
votes
7 answers

org.glassfish.jersey.internal.RuntimeDelegateImpl NOT FOUND

I am using jersey for my project and tring to parse a URI from a string. UriBuilder.fromUri("http://localhost:8000").build(); The code is simple, but I get a error below java.lang.ClassNotFoundException:…
Spark8006
  • 635
  • 1
  • 7
  • 15
46
votes
2 answers

JAX-RS (Jersey) custom exception with XML or JSON

I have a REST service built using Jersey. I want to be able to set the MIME of my custom exception writers depending on the MIME that was sent to the server. application/json is returned when json is received, and application/xml when xml is…
Oskar
  • 1,047
  • 2
  • 12
  • 19
46
votes
6 answers

Handling custom error response in JAX-RS 2.0 client library

I am starting to use the new client API library in JAX-RS and really loving it so far. I have found one thing I cannot figure out however. The API I am using has a custom error message format that looks like this for example: { "code": 400, …
Chuck M
  • 1,175
  • 3
  • 17
  • 26
46
votes
3 answers

In JAX RS, differences between returning Response and Bean or Collection of Beans (DTO)

I am working on building a REST api. My question is, when using Jersey, what are the differences between my services building and returning a Response object or returning the the bean or collection. I am only concerned with successful calls, I am…
Half_Duplex
  • 5,102
  • 5
  • 42
  • 58
45
votes
4 answers

Optional @PathParam in Jax-RS

I have a service where the last part of the path is optional, the user can both enter /mypath/ and /mypath/param1/. I tried to use a regular expression to filter the last part of the path: @Path("/mypath{param1: (/param1)?}") I'm using RestEasy as…
Fábio
  • 3,291
  • 5
  • 36
  • 49
45
votes
6 answers

Design Pattern to model Request and Response Objects for Webservices

I have about 7 REST web services to implement. Some of these web services have a standard (identical) response, while some have different responses. The requests for these web services are different but some requests and some of the responses have…
DntFrgtDSemiCln
  • 1,259
  • 2
  • 16
  • 35
43
votes
3 answers

How to return a partial JSON response using Java?

I'm building a RESTful API and want to provide developers with the option to choose which fields to return in the JSON response. This blog post shows examples of how several API's (Google, Facebook, LinkedIn) allow developers to customize the…
Justin
  • 6,031
  • 11
  • 48
  • 82
43
votes
4 answers

What objects can I inject using the @Context annotation?

I'm new to JAX-RS and I'm trying to understand how the @Context annotation is supposed to work. At the javadoc there is a list of six classes (Application, UriInfo, Request, HttpHeaders, SecurityContext, Providers). However I find code on the web…
idrosid
  • 7,983
  • 5
  • 44
  • 41