You can use renderToString() instead of output buffering.