It's not a secret anymore!*
The moose likes Struts and the fly likes Change text in servlet response with filter ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Change text in servlet response with filter ?" Watch "Change text in servlet response with filter ?" New topic

Change text in servlet response with filter ?

Juergen Unfried

Joined: Oct 11, 2006
Posts: 5

I have a Struts 1.x application which serves a webpage for desktop users. Now I have to do an optimized version for smartphones which is working pretty nice. For this mobile version I have to filter out all images and make telephone numbers dialable in the mobile browser.

My plan was to use a filter which works on everything with /mobile/ in the url and basically do a .replaceAll(...). The filter is called but now I am stuck because I have no clue how to change the content of the response. All I find on the net is change content types. I also tried the getWriter() method to get the printwriter but I have no clue on how to change the text content of the repsonse.

any ideas what I am overseeing?


Ankit Garg

Joined: Aug 03, 2008
Posts: 9291

Its easy to find such a thing on google. Example...

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
It is sorta covered in the JavaRanch Style Guide.
subject: Change text in servlet response with filter ?
Similar Threads
HTTP Response
How to send text message to my mobile?
HFJS: Filters + Wrappers Explaination pg 721
"After" filter?
Capturing JSP Content Within My Strut Action Servlet