You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Leszek Gawron <ou...@vip.net.pl> on 2003/03/05 11:50:19 UTC
logging request body
need help again:
I'm parsing my request body like this:
public Document GetInputStreamDocument() throws IOException {
int contentLength = request.getContentLength();
boolean failure = false;
if ( contentLength > 0 ) {
DOMBuilder builder = null;
Parser newParser = null;
try {
HttpServletRequest request =
(HttpServletRequest) objectModel.get( HttpEnvironment.HTTP_REQUEST_OBJECT );
PostInputStream anStream = new PostInputStream( request.getInputStream(), contentLength );
InputSource contentSource = new InputSource( anStream );
newParser = (Parser) this.manager.lookup(Parser.ROLE);
//document = newParser.newDocument();
builder = new DOMBuilder(newParser);
newParser.setContentHandler(builder);
newParser.setLexicalHandler(builder);
newParser.parse( contentSource );
} catch (Exception e) {
// ignore - return null
failure = true;
} finally {
if ( newParser != null )
this.manager.release((Component) newParser);
}
if ( failure )
return null;
else
return builder.getDocument();
}
return null;
}
I hope this is the proper way to do it but that is not the matter.
How can I put all the contents of request body into cocoon log file?
ouzo
--
__
| / \ | Leszek Gawron // \\
\_\\ //_/ ouzo@vip.net.pl _\\()//_
.'/()\'. Phone: +48(600)341118 / // \\ \
\\ // recursive: adj; see recursive | \__/ |