views:

635

answers:

4

Modifying the HTTP Response Using Filters

A: 

USE : response

Purpose

The response object is an instance of the Servlet API's HttpServletResponse class

Examples

class BookController { def downloadFile = { byte[] bytes = // read bytes response.outputStream << bytes } }

Description

The Servlet API's HttpServletResponse class can be used within Grails to perform all typical activities such as writing out binary data, writing directly to the response and sending error response codes to name but a few.

Samiksha
+1  A: 

I think the question relates to ASP.NET, not Java. This might help:

http://professionalaspnet.com/archive/2008/04/13/What-is-the-Difference-between-an-httpModule-and-an-httpHandler_3F00_.aspx

IrishChieftain
+1  A: 

These kind of components are called filters in the Java world. They are capable of modifying requests/responses before they are dispachted to the handler component resp. before the response is delivered to the client.

In ASP.NET these kind of components are called HTTP Modules.

mkoeller
A: 

Historically, response filters have been the way to do this in ASP.NET. However, they suffer from some serious cache-related issues, both in IIS6 (tougher to notice) and IIS7. This question includes a KB article with more detail.

Jason Weber