Studying Filters now-a-days.
i have a requirement, i want to call an HTML and add a Horinontal line before and after the HTML Generated Contents.
I have written some codes for this but there are problems. I will describe about the problems after discussing codes.
Basically i am using these classes to achieve this:-
(1) filterservletoutputstream.java for custom ServletOutputStream (2) genericresponsewrapper.java for creating HttpServletRequestWrapper (3) mygenericfilter.java for implementing init() & destroy()
(4) prepostfilter.java for getting the response from html file and generate it's own custom response
(5) prepost.html is the target html file.
Codes of these file as follows :-
Problems i am facing :-
(1) First horizontal line comes allright
(2) content of prepost.html file shows </ht in the last, i donot why it is taking it ?
(3) second horizontal line does not appear after Html content, but if i ommit out.getData() from code then this line appear.
(4) Also there is problem that if i change the phrase in first horizontal line say "Hello" to "test" for some reason it does not change even after tomcat 6 server restart.
I have done some brain storming and reached to conclusion for this.
(1) Changes in prepostfilter.java was not effecting becuase of cache, i had set to no-cache in header and it's now shows change.
(2) But the problem remains same as when output returns from html page, it commits and below horizontal line does not appear.
i came to know for this when used :-
it returns true after the line
which is actually output of HTML Page.
The revised code is as follows :-
please help me in understanding why it is commiting and hence horizontal line after html is not printing.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Filters - modify response after the target html has delivered / commited it