aspose file tools*
The moose likes Servlets and the fly likes Modify servlet output to include standard data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Modify servlet output to include standard data" Watch "Modify servlet output to include standard data" New topic
Author

Modify servlet output to include standard data

Khan Tanoli
Greenhorn

Joined: Feb 16, 2011
Posts: 6

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

Joined: Feb 16, 2011
Posts: 6

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.
 
Don't get me started about those stupid light bulbs.
 
subject: Modify servlet output to include standard data