Brantley-

as the ServletResponse.getOutputStream() returning a 
javax.servlet.ServletOutputStream is not RLE (RunLengthEncoded)
unless of course you implement some form of Tokenizer such as 
http://forum.java.sun.com/thread.jspa?threadID=734167&tstart=420
Quickest would be to call HttpServletRequest.getContentLength() and xmit 
variable back in the response 

Yair?
M--
--------------------------------------------------------------------------- 
This e-mail message (including attachments, if any) is intended for the use of 
the individual or entity to which it is addressed and may contain information 
that is privileged, proprietary , confidential and exempt from disclosure. If 
you are not the intended recipient, you are notified that any dissemination, 
distribution or copying of this communication is strictly prohibited.
--------------------------------------------------------------------------- 
Le présent message électronique (y compris les pièces qui y sont annexées, le 
cas échéant) s'adresse au destinataire indiqué et peut contenir des 
renseignements de caractère privé ou confidentiel. Si vous n'êtes pas le 
destinataire de ce document, nous vous signalons qu'il est strictement interdit 
de le diffuser, de le distribuer ou de le reproduire.
----- Original Message ----- 
From: "Brantley Hobbs" <[EMAIL PROTECTED]>
To: "Tomcat Users List" <users@tomcat.apache.org>
Sent: Thursday, March 29, 2007 10:12 AM
Subject: Re: How do I get the response status code?


> Ahh.....please ignore my last.
> 
> I see that you're doing the same thing I mentioned (setting a private 
> variable and returning that as the status).
> 
> Is this not working for you?
> 
> Brantley
> 
> Yair Zohar wrote:
>> Hi Brantley,
>> Thanks for replying.
>> I've tried to pass a wrapper to the filter's chain, here is the 
>> wrapper's code:
>> 
>> import java.io.IOException;
>> import javax.servlet.http.*;
>> 
>> public class TestResponse extends HttpServletResponseWrapper {
>>    private int statusCode;
>>    public TestResponse(HttpServletResponse response) {
>>        super(response);
>>    }
>>    public int getStatus() {
>>        return statusCode;
>>    }
>>    public void sendError(int errorCode) throws IOException {
>>        this.statusCode = errorCode;
>>        super.sendError(errorCode);      }
>>    public void sendError(int errorCode, String errorMessage) throws 
>> IOException {
>>        this.statusCode = errorCode;
>>        super.sendError(errorCode, errorMessage);      }
>>    public void setStatus(int statusCode) {
>>        this.statusCode = statusCode;
>>        super.setStatus(statusCode);
>>    }
>> }
>> 
>> I hopped tomcat will use the wrapper's setStatus() method and then I 
>> will be able to get the status code.
>> What actually happened is that sometimes the status code returned was 0 
>> and sometimes 404 or 304. It seems tomcat used the wrapper's setStatus() 
>> method only in part of the cases (maybe only when there was a problem 
>> getting the page).
>> 
>> How does the byte count gives information on the status code ?
>> How do you get the byte count from the output stream ?
>> 
>> Yair.
>> 
>> 
>> 
>> Brantley Hobbs wrote:
>>> Yair,
>>>
>>> I too would be interested in this.  I wrote a logging filter that does 
>>> what you describe, but the best that I could come up with was a 
>>> response wrapper that was passed along the filter chain.  In the 
>>> wrapper, I could set a status, thus guaranteeing that I would end up 
>>> with a status at the end.  The wrapper extends 
>>> HttpServletResponseWrapper.
>>>
>>> You may also find a wrapper useful because response sizes are not 
>>> always set either, at least in my experience.  With the wrapper, you 
>>> can monitor the output stream to get a byte count.
>>>
>>> B.
>>>
>>> Yair Zohar wrote:
>>>> Hello,
>>>> I'm trying to create a filter that will do the access logging for my 
>>>> web application
>>>> (I would like to write the information directly to the database not 
>>>> to a file).
>>>> I have a problem to get the status code of the response.
>>>> The filter receives a ServletResponse object that do not have a 
>>>> getStatus() method.
>>>> Any idea ?
>>>> Yair Zohar.
>>>>
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To start a new topic, e-mail: users@tomcat.apache.org
>>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To start a new topic, e-mail: users@tomcat.apache.org
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>>>
>> 
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
>

Reply via email to