I fear you are right :-)
Due to the fact that you cannot read twice from the same ServletInputStream
(unfortunately you are again right here :-)) I did the following in the mean
time:
[snip]
in = request.getInputStream();
ByteArrayInputStream bais;
ByteArrayOutputStream baos;
try {
byte [] buffer;
baos = new ByteArrayOutputStream();
byte buf[] = new byte[1024];
int letti;
System.out.println("***************************************");
while ((letti=in.read(buf))>0) {
System.out.print(new String(buf));
baos.write(buf,0,letti);
buf = new byte[1024];
}
System.out.println("***************************************");
buffer = baos.toByteArray();
bais = new ByteArrayInputStream(buffer);
in = bais;
} catch (Exception e) { e.printStackTrace(); }
[/snip]
The above code reads the ServletInputStream into a byte buffer and hands on a
ByteArrayInputStream from this buffer to my application (which in turn reads
from the ByteArrayInputStream and does not attempt to read the initial
ServletInputStream twice/again).
Is it possible to transfer this code into a valve as well?
markus
-------- Original-Nachricht --------
> Datum: Tue, 11 Nov 2008 16:27:57 -0500
> Von: Christopher Schultz <[EMAIL PROTECTED]>
> An: Tomcat Users List <[email protected]>
> Betreff: Re: log POST data
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Markus,
>
> Markus Reis wrote:
> > OK (therefore I wrote POST data in the subject) - How could I log this
> (POST) data (or body)?
>
> It doesn't look like there's an option in there for this:
>
> http://tomcat.apache.org/tomcat-6.0-doc/api/org/apache/catalina/valves/ExtendedAccessLogValve.html
>
> Care to write one? Just be aware that parsing the request body in a
> Valve means that you need to save the request body for any other code
> that wants to read it using request.getReader or request.getInputStream.
> Not a trivial exercise.
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAkkZ+N0ACgkQ9CaO5/Lv0PAC3wCeMl0beYqFjHDhnS7fsj2y8qS8
> T9QAn1c7MxfIe7Rh19LbdJaYBTBR2XHK
> =SPFU
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: [email protected]
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
--
Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen:
http://www.gmx.net/de/go/multimessenger
---------------------------------------------------------------------
To start a new topic, e-mail: [email protected]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]