Last updated May 14, 2009 08:06, by Igor Minar


Project News

2009-05-14 grizzly-sendfile 0.3 is out!
2009-05-10 grizzly-sendfile and Comparison of Blocking and NonBlocking IO
2009-02-05 Project Announcement

What is it?

grizzly-sendfile is an extension for grizzly - a NIO framework that among other things powers GlassFish application server.

The goal of this extension is to facilitate an efficient file transfer functionality, which would allow applications to delegate file transfers to the application server, while retaining control over which file to send, access control or any other application specific logic.

The name comes from the X-Sendfile HTTP header that is used to send instructions between the application and the extension. X-Sendfile is already supported by many web servers e.g. Apache, Lighttpd, but is unfortunately is not commonly used by JavaEE application servers.

grizzly-sendfile 0.2 is compatible with grizzly 1.0.x (used in GlassFish 2.0 and 2.1). The soon to be released 0.3 version is compatible with grizzly 1.9.15+ (used in GlassFish v3b48+).

When should I use it?

grizzly-sendfile extension is an ideal solution when you want to:

  • add file sending functionality to an application
  • control access to files via custom authentication and authorization in your application
  • allow http clients to access files that are not directly accessible by the app/web server
  • simply send files wickedly fast to many clients

What are the benefits?

  • decouples the file sending logic from the application logic
  • optimized for speed and scalability
  • significantly reduces memory consumption of the application server
  • downloads are handled separately from regular http traffic, allowing application to be responsive even when there are many downloads in progress
  • JMX instrumentation for runtime monitoring
  • extensible via plugins
  • works with any application written in any language or using any framework supported by GlassFish/grizzly

How do I use it?

Getting started with grizzly-sendfile is pretty easy.

  1. Configure your grizzly or GlassFish server.
  2. In your application, instead of generating any kind of response content, just set "X-Sendfile" response header with a value corresponding to the file you want grizzly-sendfile to send to the user.

For example in a JSP page or servlet you can simply do this:

 response.setHeader("X-Sendfile", "/path/to/file.avi");

Check out sendfile.jsp

In Ruby on Rails it's even prettier (more info):

 send_file '/path/to.png', :x_sendfile => true, :type => 'image/png'

That's it... there is no step #3. When this code is executed the response will be intercepted by grizzly-sendfile and the file will be efficiently transferred to the client.

How does grizzly-sendfile work?

Who uses grizzly-sendfile?

grizzly-sendfile is currently powering:

If your app is powered by grizzly-sendfile, let me know!


  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2014, Oracle Corporation and/or its affiliates
(revision 20160708.bf2ac18)
Please Confirm