java - Read response before send it -
java - Read response before send it -
i sending plain text file user through servlet.
i using flatworm framework build flat file. receive file in browser empty. want start debugging analysing outputstream before beingness sent.
how can read response before send in servlet? think same thing asking how can transform outputstream inputstream.
i saw solutions involve bytearrayoutputstream , , know when phone call in servlet response.getoutputstream() returns me outputstream , not bytearrayoutputstream.
there seems confusion somewhere, though i'm not sure where.
what can outputstream? why, can write it, , that's it. means if you're given (or up) output stream, it's supply info - means have it.
perhaps on other hand, you're not straight calling write on outputstream yourself, passing stream flatworm library (which in turn write output it). in case, there's debugging "hook" right there - flatworm write out file output stream send it. in case, instead of passing in servlet's stream, pass in stream you've created yourself.
that might bytearrayoutputstream, (after flatworm method has returned) can inspect bytes written. @ point manually write them through response's output stream. or maybe need trickier , create own stream wrapper writes straight through underlying response stream logs on way - , pass flatworm.
the bottom line if you're interacting output stream, "your" code has info somewhere locally , it's matter of capturing/accessing that.
java servlets outputstream
Comments
Post a Comment