users@jersey.java.net

[Jersey] Re: Pagination

From: Van Klaveren, Brian N. <bvan_at_slac.stanford.edu>
Date: Sat, 6 Sep 2014 18:30:03 +0000

Hi,

I just want to mention that there’s a way of paginating with headers that uses the normal Range header so you don’t need to create new headers, but I believe it should (can?) only be used when an Range header is sent.

In the HTTP spec, it specifies that an arbitrary range unit may be used instead of bytes, which is the normal range unit. Since the units can be completely arbitrary, you can use “items” or “resources” or whatever, for example.

Here is an example.
https://restful-api-design.readthedocs.org/en/latest/methods.html#ranges-pagination

And another link just so you can see how Range requests might work:
http://stackoverflow.com/a/8507991/517862

Brian


On Sep 4, 2014, at 1:01 PM, Nishant Chandra <nishant_at_ncredibles.com> wrote:

> Hi,
>
> I have been trying to find a good way to implement pagination for an API and came across few options e.g. use headers or query params.
>
> Has anyone tried this with Jersey (in combination with Spring JPA) ? Any pointers to a sample code will be helpful.
>
> Thanks,
> Nishant