You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Eugene Prigarov <Eu...@enterra-inc.com> on 2004/03/16 14:09:24 UTC

ResponseOutputStream.setHeader() & ResponseOutputStream.setContentType() problems

Hi. Sorry for encoding problems in bug report.

 

I thing I found serious bag in Tapestry AbstractService engine.

I was trying to create my own ResourceService extending AbstactService
as shown in Workbench (ChartService), and I found this:

 

Setting content type or header of output stream in service() method of
my service class like this:

 

public void service( IEngineServiceView engine, IRequestCycle cycle,
ResponseOutputStream output ) throws ServletException, IOException

{

        try

        {

...

            output.setContentType( "video/x-msvideo" );

            output.setHeader( "Pragma", "no-cache" );

...

            output.write( data );

        }

        catch( IOException e )

        {

            log.error( "recepient closed the stream or connection
closed" );

            output.close();

            return;

        }

}

 

Don't WORK.

The result http response, have no ANY header information. I have
repeated this experiment with ChartService of Workbench with same
result. Headers don't set.

This is very important because of embedded objects don't understand the
streams without content type. That's why it is not possible to use
constructions like this in html pages (especially with old version of
mediaplayers):

 

<embed jwcid="@Any" src="ognl:url" type="ognl:contentType"  width="232"
height="200"/>

 

There url property point to the service.

 

Maybe problem is in direct using OutputStream instead using PrintWriter
of HttpServletResponse in these and other places. 

 

private void open() throws IOException

    {

...

        _out = _response.getOutputStream();

 

...

 }

 

    private void innerWrite( byte[] b, int off, int len ) throws
IOException

    {

...

            _out.write( b, off, len );

...

    }

 

Maybe rather to write data using PrintWriter.print() method. 

 


RE: ResponseOutputStream.setHeader() & ResponseOutputStream.setContentType() problems

Posted by Mind Bridge <mi...@yahoo.com>.
Hi,

This sound pretty serious, but I have a few questions.

Content Type:
I just checked with the current Tapestry build, and the content type is
passed for sure.
To check you can change the type specified in ChartService.java and as a
result the content type returned by the response changes approprately --
just did a quick test to verify.

Headers:
I am a bit surprised by this line in your code:
> output.setHeader( "Pragma", "no-cache" );

ResponseOutputStream does not actually have a method 'setHeader'.
(perhaps it should, but that's another discussion)

My guess is that you are using a modified version of Tapestry. This could
explain both why you have setHeader(), and why setContent() does not work
for you.

Could you check? May be the answer to your problem is in the modifications.

-mb

-----Original Message-----
From: Eugene Prigarov [mailto:Eugene.Prigarov@enterra-inc.com]
Sent: Tuesday, March 16, 2004 3:09 PM
To: tapestry-dev@jakarta.apache.org
Subject: ResponseOutputStream.setHeader() &
ResponseOutputStream.setContentType() problems


Hi. Sorry for encoding problems in bug report.



I thing I found serious bag in Tapestry AbstractService engine.

I was trying to create my own ResourceService extending AbstactService
as shown in Workbench (ChartService), and I found this:



Setting content type or header of output stream in service() method of
my service class like this:



public void service( IEngineServiceView engine, IRequestCycle cycle,
ResponseOutputStream output ) throws ServletException, IOException

{

        try

        {

...

            output.setContentType( "video/x-msvideo" );

            output.setHeader( "Pragma", "no-cache" );

...

            output.write( data );

        }

        catch( IOException e )

        {

            log.error( "recepient closed the stream or connection
closed" );

            output.close();

            return;

        }

}



Don't WORK.

The result http response, have no ANY header information. I have
repeated this experiment with ChartService of Workbench with same
result. Headers don't set.

This is very important because of embedded objects don't understand the
streams without content type. That's why it is not possible to use
constructions like this in html pages (especially with old version of
mediaplayers):



<embed jwcid="@Any" src="ognl:url" type="ognl:contentType"  width="232"
height="200"/>



There url property point to the service.



Maybe problem is in direct using OutputStream instead using PrintWriter
of HttpServletResponse in these and other places.



private void open() throws IOException

    {

...

        _out = _response.getOutputStream();



...

 }



    private void innerWrite( byte[] b, int off, int len ) throws
IOException

    {

...

            _out.write( b, off, len );

...

    }



Maybe rather to write data using PrintWriter.print() method.





---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org