Reputation: 2673
I have a simple application which renders a jsp file into the browser after getting some data from a servlet.Now I want to add some data in the form of some HTML Tag into the response object coming out of the jsp.
I have made a filter and response wrapper which overrides the getWriter method by returning a custom PrintWriter as:
StringWriter sw = new StringWriter();
public PrintWriter getWriter() {
return new PrintWriter(sw);
}
Now I am able to retrieve the string from this response object using getString function
public getString(){
return sw.toString();
}
And I am able to add the content in the string using
str.split("<tag where I have to add>");
But now I want to render this string into my Browser.
Will I have to create some other Wrapper object? Or please suggest any other way to achieve this.Any help will be appreciated.
Thanks.
Upvotes: 1
Views: 893
Reputation: 10115
You are overruling the existing writer of the response object. You should keep a reference to that one and in the end write the final/modified content to that writer.
Upvotes: 1