request « jersey « Java Enterprise Q&A

1. How to get full REST request body using Jersey?

How can one get the full HTTP REST request body for a POST request using Jersey? In our case the data will be XML. Size would vary from 1K to 1MB. The ...

2. Multiple return type in Jersey Client request

I'm using Jersey Client API in the following way :-

User user = webRsrc.accept(MediaType.APPLICATION_XML).post(User.class, usr);
So I'm expecting the response in object of User class which is a JAXB annotated class. However, at times ...

3. Can a Jersey GET request return a polymorphic entity?

I've got a Resource class that attempts to return an interface type, say "Shape":

public interface Shape {...}

public class Circle implements Shape {...}

public class ShapeResource {

4. How should I mock Jersey HTTP-client requests?

This is the class I'm trying to test (it calculates the size of HTTP page):

import com.sun.jersey.api.client.*;
public class Loader {
  private Client client;
  public Loader(Client c) {

5. Can I wrap all JAX-RS requests with custom pre-dispatch, post-dispatch and error-handler code?

I have a number of classes exposed as JAX-RS request "handlers", using annotations. I want to add certain actions before every request and after each request. Also, I need to ...

6. Get an OuputStream to a request body using Jersey Client?

I wan't to post a CSV file to a web service using the Jersey Client without having to buffer the csv content in memory. So I started of with some code similar ...

7. How to route JAX-RS request conditionally, depending on the suffix?

This is what I'm trying to do:

public class Finder {
  public Proxy find(@PathParam("name") String name) {
    Object found = /* some object found by name ...

8. 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 ...

9. Get the Domain that an Ajax Request is coming from

I have a set of JSONP Web Service created on my J2EE application, which will be used by a website under a different domain. The web services have been created using ...

10. How do I access the HTTP request?

Say normally I have a rest method in java

    public String showTime(@FormParam("username") String userName) {

which is fine, however I'm ...

11. How can I programatically reigster request methods (GET/POST/PUT) in Jersey, without using annotations?

The question is in the title. Thanks for responding.

12. Content-Length-Header not set in Jersey Client request

I'm using Jersey Client to access a webservice, like this:
response = r.accept(MediaType.TEXT_PLAIN_TYPE).header("content-length", 0).post(String.class);
where r is a WebResource However, the Webservice returns 411 - Content-Length is missing. using tcpdump, i found out that ...

13. Jersey REST WS - request body UTF-8

I have simple Jersey REST webServices:

public Response setLabels(String requestBody) { 
Request passes some text with "special" non-English characters
 [{"?? ??????"}]
I can ...

14. Mule/Jersey returning 400 on requests for file upload

I'm writing a mule application that implements some web services using Jersey. I'd like to upload a file. I've written the following skeleton

public String getSummaryHtml(

15. Jersey REST Client: How to add XML file to the body of POST request?

My code so far:

FileReader fileReader = new FileReader("filename.xml");
Client c = Client.create();
WebResource webResource = c.resource("http://localhost:8080/api/resource");
I want to send contents of filename.xml with POST method but I have no idea how to add ...

16. Jersey Client: Adding Cookies to Request

I am trying to write a library that accesses a RESTful web service using the Jersey Client API. The service requires a login request that sets a cookie, then subsequent ...

17. Jersey: Print the actual request

How can I view the actual request that Jersey generates and sends to the server? I am having issues with a particular request and the fellow running the webserver asked ...

18. How to enable resumable GET requests with Jersey?

I am creating a RESTful web service using Jersey. Some of the resources are binary files that I get from somewhere else on demand; such files are potentially big (hundreds of ...

19. API Development: When to return a BAD REQUEST HTTP Status Code (REST)

We're authoring REST services, and there's a debate on what to do when someone requests a resource with a parent ID that does not exist. Example: You are asking for a ...

20. How to access multiple resources in a single request : Jersey Rest

I am trying to a find a good design for the following scenario. I have a POST rest service which will be given an array of services as data. And which should ...