This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

manipulate HttpServletResponse content in ServletFilter

 
Joe carco
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's possible by creating a wrapper around the response. See http://www.oracle.com/technetwork/java/filters-137243.html for an example.
 
amit punekar
Ranch Hand
Posts: 544
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I had written a small example earlier on this.
Check it out here.

Regds,
Amit
 
Joe carco
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ulf! that was exactly what I was looking for!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic