Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Modifying HTTP response content with a servlet filter

Hi,

I need to modify the content of responses, so I'm writing a filter.

I found a couple of different approaches here:
https://stackoverflow.com/questions/14736328/looking-for-an-example-for-inserting-content-into-the-response-using-a-servlet-f#14736818

The simpler solution from iTech works - but only when directly requesting a file.

i.e. example.com/dir/index.html works, but example.com/dir/ returns the unmodified content of index.html

The longer (accepted) solution works in both cases, so I'm guessing its convoluted use of getOutputStream/etc is somehow relevant to it working, but I don't see why the same file triggers different behaviour, just because it's going via the default/welcome file mechanism.

Is it really necessary to jump through all those hoops in order to get and set response content, or am I missing some simpler way?


Thanks,

Peter



Back to the top