• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Modify servlet output to include standard data

 
Greenhorn
Posts: 6
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
actually i do have a question in reference to this. And i figured instead of opening a new thread, i'll ask here as the OP's question seems related to what i want to.

What i want to do is to insert a hidden form field in all my pages dynamically by "scanning" the response object and then if the response content has <form> tags in it, then for each form insert the hidden field. I could do this manually, but way too many jsp's and a dynamic solution would be much more elegant.

I have created wrapper class for the response object and another wrapper for ServletOutputStream. The problem i have are two:

a) i can't seem to get the content read out from the response, without preventing the response jsp to display in the browser, as the front end browser only displays blank screen.

b) is this possible? meaning injecting code into the stream as it is going to the end user? I looked at the compressione example in the Head First Servlets and JSP, but i have not been able to find it helpful in my case as i'm trying to add data to the response.

Thanks for any and all feedback.
 
Khan Tanoli
Greenhorn
Posts: 6
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay i have figured the above out, but now i'm running into another issue. Once i wrap the output stream, whatever is the last tile insert definition in my jsp, it is not getting processed.

By this i mean that the content of the last tile insert is missing from the page on the front end. If input a dummy tile insert after the last "actual" tile insert, it works and i am able to see the content of that tile.

Has anybody else experienced this behavior? I have looked through my implementation and i am not prematurely closing the stream anywhere so not sure what is happening. I am using Struts 1.2.*, and not sure if this is related to that version of struts or my implementation. In my WAS server logs i do see the message "****.jsp intialization successful." So i know it's getting acquired by the webserver.

Any feedback is appreciated. Thanks.
 
God is a comedian playing for an audience that is afraid to laugh - Voltair. tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic