• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
  • Himai Minh
  • Carey Brown
  • salvin francis

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

Ranch Hand
Posts: 47
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
vijay dadhwal
Ranch Hand
Posts: 47
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

That new kid is a freak. Show him this tiny ad:
the value of filler advertising in 2020
    Bookmark Topic Watch Topic
  • New Topic