You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Paul Hunnisett <de...@lombok.org.uk> on 2002/11/11 12:14:48 UTC

ServletOutputStreamWrapper

I have been examining the source code for
org.apache.catalina.util.ssi.ServletOutputStreamWrapper and I discovered
a writeTo() method that writes the current buffer to the OutputStream. 
What I can't quite see is how this method would be called.  It is not
part of the servlet spec, so the web application won't be calling it. 
So I assume that the server calls it, but how does the server know when
to write the buffer out? 

Any information would be appreciated.

Paul Hunnisett





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: ServletOutputStreamWrapper

Posted by Paul Hunnisett <de...@lombok.org.uk>.
Is anyone familiar with this class?  

On Mon, 2002-11-11 at 11:14, Paul Hunnisett wrote:
> I have been examining the source code for
> org.apache.catalina.util.ssi.ServletOutputStreamWrapper and I discovered
> a writeTo() method that writes the current buffer to the OutputStream. 
> What I can't quite see is how this method would be called.  It is not
> part of the servlet spec, so the web application won't be calling it. 
> So I assume that the server calls it, but how does the server know when
> to write the buffer out? 
> 
> Any information would be appreciated.
> 
> Paul Hunnisett
> 
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: ServletOutputStreamWrapper

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On 14 Nov 2002, Paul Hunnisett wrote:

> Date: 14 Nov 2002 20:05:07 +0000
> From: Paul Hunnisett <de...@lombok.org.uk>
> Reply-To: Tomcat Developers List <to...@jakarta.apache.org>
> To: Tomcat Developers List <to...@jakarta.apache.org>
> Subject: Re: ServletOutputStreamWrapper
>
> Thanks Craig, I'll take a look at that - hope fully it'll help me to
> move forward.  I'm somewhat confused though - surely Tomcat must have
> subclasses of ServletInputStream and ServletOutputStream?

It certainly does, but they're not going to be of direct use to your own
application because they are intimately connected to the rest of the HTTP
connector implementation.

>  What gets
> returned when an application call request.getInputStream() or
> response.getOutputStream?
>

For Tomcat 4.x (for example), you'll end up with an instance of the
internal class org.apache.coyote.tomcat4.Coyote{Input,Output}Stream.  The
sources are in the "jakarta-tomcat-connectors" repository, under "coyote".

> Paul Hunnisett
> www.lombok.org.uk

Craig


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: ServletOutputStreamWrapper

Posted by Paul Hunnisett <de...@lombok.org.uk>.
Thanks Craig, I'll take a look at that - hope fully it'll help me to
move forward.  I'm somewhat confused though - surely Tomcat must have
subclasses of ServletInputStream and ServletOutputStream?  What gets
returned when an application call request.getInputStream() or
response.getOutputStream?

Paul Hunnisett
www.lombok.org.uk



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: ServletOutputStreamWrapper

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On 12 Nov 2002, Paul Hunnisett wrote:

> Date: 12 Nov 2002 19:38:18 +0000
> From: Paul Hunnisett <de...@lombok.org.uk>
> Reply-To: Tomcat Developers List <to...@jakarta.apache.org>
> To: Tomcat Developers List <to...@jakarta.apache.org>
> Subject: Re: ServletOutputStreamWrapper
>
> Thanks Dan, I'll try that.  Basically what I'm trying to do is to write
> my own subclasses of ServletOutputStream and ServletInputStream and I
> need a little bit of inspiration - especially with the write(int) and
> read() methods that I have to override.
>

In the "examples" webapp shipped with Tomcat, there's a compression filter
that (among other things) creates a ServletResponseWrapper subclass and
uses a specialized response stream implementation (extends
ServletOutputStream).  The sources are in the
"/WEB-INF/classes/compressionFilters" subdirectory of the example webapp.

Craig


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: ServletOutputStreamWrapper

Posted by Paul Hunnisett <de...@lombok.org.uk>.
Thanks Dan, I'll try that.  Basically what I'm trying to do is to write
my own subclasses of ServletOutputStream and ServletInputStream and I
need a little bit of inspiration - especially with the write(int) and
read() methods that I have to override.

On Tue, 2002-11-12 at 19:06, Dan Sandberg wrote:
> Paul, it would be a lot easier to help if I knew what you were trying to 
> do specifically.
> 
> If you want to find a class that extends another, why not just search 
> the source-code textually?
> 
> On my unix system, I just do:
> 
> findj "extends ServletOutputStream"
> 
> where findj is an alias:
> 
> alias findj='find . -name "*.java" -not -path "*/autogenerated/*" | 
> xargs grep'
> 
> which returns:
> 
> ./util/ssi/ServletOutputStreamWrapper.java:    extends ServletOutputStream {
> ./connector/ResponseStream.java:    extends ServletOutputStream {
> 
> -Dan
> 
> Paul Hunnisett wrote:
> 
> >Actually, a good example of a ServletInputStream subclass with a read()
> >implementation would be helpful too.  I am trying to find al lthese
> >examples in the source, but am haviong limited success tracking down the
> >appropriate classes
> >
> >On Tue, 2002-11-12 at 10:13, Paul Hunnisett wrote:
> >  
> >
> >>The main reason I was looking at this class in the first place was to
> >>try to find a good way of overriding the write(int) method of
> >>OutputStream in a server context. Is there another class which extends
> >>ServletOutputStream and would give me a more real world example?
> >>
> >>On Tue, 2002-11-12 at 00:03, Dan Sandberg wrote:
> >>    
> >>
> >>>Hi Paul.
> >>>
> >>>That class is specific to the server-side include code, so the server 
> >>>doesn't need to know anything about the writeTo method.  
> >>>
> >>>Basically, the ServletOutputStreamWrapper is used so that we can capture 
> >>>the result of Tomcat processing a page, so that we may include the 
> >>>contents of one page within another.
> >>>
> >>>o.a.c.servlets.SsiInvokerServlet calls the writeTo method.  If you have 
> >>>any questions after looking at the source-code, let us know.
> >>>
> >>>      
> >>>
> >>>>Is anyone familiar with this class?  
> >>>>        
> >>>>
> >>>Yup.
> >>>
> >>>-Dan
> >>>
> >>>Paul Hunnisett wrote:
> >>>
> >>>      
> >>>
> >>>>I have been examining the source code for
> >>>>org.apache.catalina.util.ssi.ServletOutputStreamWrapper and I discovered
> >>>>a writeTo() method that writes the current buffer to the OutputStream. 
> >>>>What I can't quite see is how this method would be called.  It is not
> >>>>part of the servlet spec, so the web application won't be calling it. 
> >>>>So I assume that the server calls it, but how does the server know when
> >>>>to write the buffer out? 
> >>>>
> >>>>Any information would be appreciated.
> >>>>
> >>>>Paul Hunnisett
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>--
> >>>>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> >>>>For additional commands, e-mail: <ma...@jakarta.apache.org>
> >>>>
> >>>>
> >>>> 
> >>>>
> >>>>        
> >>>>
> >>>
> >>>--
> >>>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> >>>For additional commands, e-mail: <ma...@jakarta.apache.org>
> >>>
> >>>      
> >>>
> >>
> >>
> >>--
> >>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> >>For additional commands, e-mail: <ma...@jakarta.apache.org>
> >>
> >>    
> >>
> >
> >
> >
> >
> >--
> >To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> >For additional commands, e-mail: <ma...@jakarta.apache.org>
> >
> >
> >  
> >
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: ServletOutputStreamWrapper

Posted by Dan Sandberg <x...@cs.stanford.edu>.
Paul, it would be a lot easier to help if I knew what you were trying to 
do specifically.

If you want to find a class that extends another, why not just search 
the source-code textually?

On my unix system, I just do:

findj "extends ServletOutputStream"

where findj is an alias:

alias findj='find . -name "*.java" -not -path "*/autogenerated/*" | 
xargs grep'

which returns:

./util/ssi/ServletOutputStreamWrapper.java:    extends ServletOutputStream {
./connector/ResponseStream.java:    extends ServletOutputStream {

-Dan

Paul Hunnisett wrote:

>Actually, a good example of a ServletInputStream subclass with a read()
>implementation would be helpful too.  I am trying to find al lthese
>examples in the source, but am haviong limited success tracking down the
>appropriate classes
>
>On Tue, 2002-11-12 at 10:13, Paul Hunnisett wrote:
>  
>
>>The main reason I was looking at this class in the first place was to
>>try to find a good way of overriding the write(int) method of
>>OutputStream in a server context. Is there another class which extends
>>ServletOutputStream and would give me a more real world example?
>>
>>On Tue, 2002-11-12 at 00:03, Dan Sandberg wrote:
>>    
>>
>>>Hi Paul.
>>>
>>>That class is specific to the server-side include code, so the server 
>>>doesn't need to know anything about the writeTo method.  
>>>
>>>Basically, the ServletOutputStreamWrapper is used so that we can capture 
>>>the result of Tomcat processing a page, so that we may include the 
>>>contents of one page within another.
>>>
>>>o.a.c.servlets.SsiInvokerServlet calls the writeTo method.  If you have 
>>>any questions after looking at the source-code, let us know.
>>>
>>>      
>>>
>>>>Is anyone familiar with this class?  
>>>>        
>>>>
>>>Yup.
>>>
>>>-Dan
>>>
>>>Paul Hunnisett wrote:
>>>
>>>      
>>>
>>>>I have been examining the source code for
>>>>org.apache.catalina.util.ssi.ServletOutputStreamWrapper and I discovered
>>>>a writeTo() method that writes the current buffer to the OutputStream. 
>>>>What I can't quite see is how this method would be called.  It is not
>>>>part of the servlet spec, so the web application won't be calling it. 
>>>>So I assume that the server calls it, but how does the server know when
>>>>to write the buffer out? 
>>>>
>>>>Any information would be appreciated.
>>>>
>>>>Paul Hunnisett
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>--
>>>>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>>>>For additional commands, e-mail: <ma...@jakarta.apache.org>
>>>>
>>>>
>>>> 
>>>>
>>>>        
>>>>
>>>
>>>--
>>>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>>>For additional commands, e-mail: <ma...@jakarta.apache.org>
>>>
>>>      
>>>
>>
>>
>>--
>>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>>For additional commands, e-mail: <ma...@jakarta.apache.org>
>>
>>    
>>
>
>
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
>  
>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Tomcat I/O

Posted by Paul Hunnisett <pa...@blueyonder.co.uk>.
I assume that somewhere in Tomcat are some classes that extend
ServletOutputStream and ServletInputStream?  I've been looking through
the source trying to find them but I'm afraid I can't see what they
are.  Is anyone able to shed any light on this for me?

Paul Hunnisett
www.lombok.org.uk


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: ServletOutputStreamWrapper

Posted by Paul Hunnisett <de...@lombok.org.uk>.
Actually, a good example of a ServletInputStream subclass with a read()
implementation would be helpful too.  I am trying to find al lthese
examples in the source, but am haviong limited success tracking down the
appropriate classes

On Tue, 2002-11-12 at 10:13, Paul Hunnisett wrote:
> The main reason I was looking at this class in the first place was to
> try to find a good way of overriding the write(int) method of
> OutputStream in a server context. Is there another class which extends
> ServletOutputStream and would give me a more real world example?
> 
> On Tue, 2002-11-12 at 00:03, Dan Sandberg wrote:
> > Hi Paul.
> > 
> > That class is specific to the server-side include code, so the server 
> > doesn't need to know anything about the writeTo method.  
> > 
> > Basically, the ServletOutputStreamWrapper is used so that we can capture 
> > the result of Tomcat processing a page, so that we may include the 
> > contents of one page within another.
> > 
> > o.a.c.servlets.SsiInvokerServlet calls the writeTo method.  If you have 
> > any questions after looking at the source-code, let us know.
> > 
> > >Is anyone familiar with this class?  
> > 
> > Yup.
> > 
> > -Dan
> > 
> > Paul Hunnisett wrote:
> > 
> > >I have been examining the source code for
> > >org.apache.catalina.util.ssi.ServletOutputStreamWrapper and I discovered
> > >a writeTo() method that writes the current buffer to the OutputStream. 
> > >What I can't quite see is how this method would be called.  It is not
> > >part of the servlet spec, so the web application won't be calling it. 
> > >So I assume that the server calls it, but how does the server know when
> > >to write the buffer out? 
> > >
> > >Any information would be appreciated.
> > >
> > >Paul Hunnisett
> > >
> > >
> > >
> > >
> > >
> > >--
> > >To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> > >For additional commands, e-mail: <ma...@jakarta.apache.org>
> > >
> > >
> > >  
> > >
> > 
> > 
> > 
> > --
> > To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> > For additional commands, e-mail: <ma...@jakarta.apache.org>
> > 
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: ServletOutputStreamWrapper

Posted by Paul Hunnisett <de...@lombok.org.uk>.
The main reason I was looking at this class in the first place was to
try to find a good way of overriding the write(int) method of
OutputStream in a server context. Is there another class which extends
ServletOutputStream and would give me a more real world example?

On Tue, 2002-11-12 at 00:03, Dan Sandberg wrote:
> Hi Paul.
> 
> That class is specific to the server-side include code, so the server 
> doesn't need to know anything about the writeTo method.  
> 
> Basically, the ServletOutputStreamWrapper is used so that we can capture 
> the result of Tomcat processing a page, so that we may include the 
> contents of one page within another.
> 
> o.a.c.servlets.SsiInvokerServlet calls the writeTo method.  If you have 
> any questions after looking at the source-code, let us know.
> 
> >Is anyone familiar with this class?  
> 
> Yup.
> 
> -Dan
> 
> Paul Hunnisett wrote:
> 
> >I have been examining the source code for
> >org.apache.catalina.util.ssi.ServletOutputStreamWrapper and I discovered
> >a writeTo() method that writes the current buffer to the OutputStream. 
> >What I can't quite see is how this method would be called.  It is not
> >part of the servlet spec, so the web application won't be calling it. 
> >So I assume that the server calls it, but how does the server know when
> >to write the buffer out? 
> >
> >Any information would be appreciated.
> >
> >Paul Hunnisett
> >
> >
> >
> >
> >
> >--
> >To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> >For additional commands, e-mail: <ma...@jakarta.apache.org>
> >
> >
> >  
> >
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: ServletOutputStreamWrapper

Posted by Dan Sandberg <x...@cs.stanford.edu>.
Hi Paul.

That class is specific to the server-side include code, so the server 
doesn't need to know anything about the writeTo method.  

Basically, the ServletOutputStreamWrapper is used so that we can capture 
the result of Tomcat processing a page, so that we may include the 
contents of one page within another.

o.a.c.servlets.SsiInvokerServlet calls the writeTo method.  If you have 
any questions after looking at the source-code, let us know.

>Is anyone familiar with this class?  

Yup.

-Dan

Paul Hunnisett wrote:

>I have been examining the source code for
>org.apache.catalina.util.ssi.ServletOutputStreamWrapper and I discovered
>a writeTo() method that writes the current buffer to the OutputStream. 
>What I can't quite see is how this method would be called.  It is not
>part of the servlet spec, so the web application won't be calling it. 
>So I assume that the server calls it, but how does the server know when
>to write the buffer out? 
>
>Any information would be appreciated.
>
>Paul Hunnisett
>
>
>
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
>  
>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>