File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Filters - modify response after the target html has delivered / commited it Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Filters - modify response after the target html has delivered / commited it" Watch "Filters - modify response after the target html has delivered / commited it" New topic
Author

Filters - modify response after the target html has delivered / commited it

vijay dadhwal
Ranch Hand

Joined: Dec 02, 2008
Posts: 47

Hi Guys,
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.

please help me
Regards
vj
>


MCA , SJCP
vijay dadhwal
Ranch Hand

Joined: Dec 02, 2008
Posts: 47

Dear All,

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.

Regards
vj
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Filters - modify response after the target html has delivered / commited it