aspose file tools*
The moose likes Servlets and the fly likes manipulate HttpServletResponse content in ServletFilter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "manipulate HttpServletResponse content in ServletFilter" Watch "manipulate HttpServletResponse content in ServletFilter" New topic
Author

manipulate HttpServletResponse content in ServletFilter

Joe carco
Ranch Hand

Joined: Apr 14, 2009
Posts: 82
Hello,

does anyone know if its possible to change the content of an HttpServletResponse in a ServletFilter?
I know that as long as the response hasn't been committed, I can add content as follows:



but is it possible to capture the responseoutput and change its contents according to certain rules?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39552
    
  27
That's possible by creating a wrapper around the response. See http://www.oracle.com/technetwork/java/filters-137243.html for an example.


Ping & DNS - updated with new look and Ping home screen widget
amit punekar
Ranch Hand

Joined: May 14, 2004
Posts: 507
Hi,
I had written a small example earlier on this.
Check it out here.

Regds,
Amit
Joe carco
Ranch Hand

Joined: Apr 14, 2009
Posts: 82
Thanks Ulf! that was exactly what I was looking for!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: manipulate HttpServletResponse content in ServletFilter
 
Similar Threads
Set Reponse Headers Problem
if a user enter a website without entering the authentication page how can i redirect
JSF Filter prevent direct access certain page
can't print after post doFilter
Asynchronous Filter post processing