You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jordan Redner <jr...@shopping.com> on 2005/02/11 19:26:33 UTC

Setting the response content-Type

I'm having trouble setting the output page content type for a Tapestry
page...

In the page backing class, I do something like...


    private static final String RESPONSE_TYPE =
"application/vnd.ms-excel";


    public void renderPage(IMarkupWriter writer, IRequestCycle cycle) {

        HttpServletResponse response =
cycle.getRequestContext().getResponse();
        response.setContentType(RESPONSE_TYPE);


	writer.printRaw(myStuff);

}

I'm getting the output in the browser instead of my desired result which
is to popup an open/save-as dialogue.

Is there something more I need to do?


Thanks in advance,


Jordan



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


Re: Setting the response content-Type [auf Viren geprueft]

Posted by Jonathan O'Connor <Jo...@xcom.de>.
If you want to be nice to the user, you can also specify the size in bytes 
as part of the Content-Disposition. Just make sure it doesn't come after 
the filename. Some browsers don't like that.
WRONG: 
resp.addHeader("Content-Disposition", "attachment; filename=report.xls; 
size=" + file.getSize());
RIGHT:
resp.addHeader("Content-Disposition", "attachment; size=" + file.getSize() 
+ "; filename=report.xls");
Ciao,
Jonathan O'Connor
XCOM Dublin



Andreas Andreou <an...@di.uoa.gr> 
11/02/2005 18:44
Please respond to
"Tapestry users" <ta...@jakarta.apache.org>


To
Tapestry users <ta...@jakarta.apache.org>
cc

Subject
Re: Setting the response content-Type [auf Viren geprueft]






You have to add the Content-Disposition header to the response to make 
the file
downloadble ( and not inline), i.e. do something like
resp.addHeader("Content-Disposition", "attachment; filename=report.xls");


Jordan Redner wrote:

>I'm having trouble setting the output page content type for a Tapestry
>page...
>
>In the page backing class, I do something like...
>
>
>    private static final String RESPONSE_TYPE =
>"application/vnd.ms-excel";
>
>
>    public void renderPage(IMarkupWriter writer, IRequestCycle cycle) {
>
>        HttpServletResponse response =
>cycle.getRequestContext().getResponse();
>        response.setContentType(RESPONSE_TYPE);
>
>
>                writer.printRaw(myStuff);
>
>}
>
>I'm getting the output in the browser instead of my desired result which
>is to popup an open/save-as dialogue.
>
>Is there something more I need to do?
>
>
>Thanks in advance,
>
>
>Jordan
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>
> 
>


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





*** Aktuelle Veranstaltungen der XCOM AG ***

XCOM laedt ein zur IBM Workplace Roadshow in Frankfurt (16.02.2005), Duesseldorf (23.02.2005) und Berlin (02.03.2005)
Anmeldung und Information unter http://lotus.xcom.de/events

Workshop-Reihe "Mobilisierung von Lotus Notes Applikationen"  in Frankfurt (17.02.2005), Duesseldorf (24.02.2005) und Berlin (05.03.2005) 
Anmeldung und Information unter http://lotus.xcom.de/events


*** XCOM AG Legal Disclaimer ***

Diese E-Mail einschliesslich ihrer Anhaenge ist vertraulich und ist allein fur den Gebrauch durch den vorgesehenen Empfaenger bestimmt. Dritten ist das Lesen, Verteilen oder Weiterleiten dieser E-Mail untersagt. Wir bitten, eine fehlgeleitete E-Mail unverzueglich vollstaendig zu loeschen und uns eine Nachricht zukommen zu lassen.

This email may contain material that is confidential and for the sole use of the intended recipient. Any review, distribution by others or forwarding without express permission is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

Re: Setting the response content-Type

Posted by Andreas Andreou <an...@di.uoa.gr>.
You have to add the Content-Disposition header to the response to make 
the file
downloadble ( and not inline), i.e. do something like
resp.addHeader("Content-Disposition", "attachment; filename=report.xls");


Jordan Redner wrote:

>I'm having trouble setting the output page content type for a Tapestry
>page...
>
>In the page backing class, I do something like...
>
>
>    private static final String RESPONSE_TYPE =
>"application/vnd.ms-excel";
>
>
>    public void renderPage(IMarkupWriter writer, IRequestCycle cycle) {
>
>        HttpServletResponse response =
>cycle.getRequestContext().getResponse();
>        response.setContentType(RESPONSE_TYPE);
>
>
>	writer.printRaw(myStuff);
>
>}
>
>I'm getting the output in the browser instead of my desired result which
>is to popup an open/save-as dialogue.
>
>Is there something more I need to do?
>
>
>Thanks in advance,
>
>
>Jordan
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>
>  
>


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