You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Ilan Azbel <ia...@mdio.net> on 2004/11/25 14:52:17 UTC
generating a binary download
I sent a similar message to the velocity mailing list but was informed that
this would probably be a better list to email with my question:
Hello,
I would like a servlet to return a binary file and thereby instruct the
browser
not to display it, but rather to download it. That is, ask the user if they
would like to "Open" or "Save" the file.
I would like to do this without any redirecting statements - so as soon as a
user requests a certain servlet, the corresponding java creates some type
of binary data, and the browser immediately asks whether to open or save
this data.
I already have an existing Turbine/Velocity application running on the same
server and I would like to use the database connections that turbine has
already make for the current web application. I don't even have any idea of
where to start with this, help?!?!
Thanks
Ilan
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
Re: generating a binary download
Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
"Ilan Azbel" <ia...@mdio.net> writes:
>I sent a similar message to the velocity mailing list but was informed that
>this would probably be a better list to email with my question:
>Hello,
>I would like a servlet to return a binary file and thereby instruct the
>browser
>not to display it, but rather to download it. That is, ask the user if they
>would like to "Open" or "Save" the file.
--- cut ---
package org.apache.turbine.apachefaces.modules.screens;
import java.io.OutputStream;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.turbine.apachefaces.model.ImageModel;
import org.apache.turbine.apachefaces.security.ApacheUser;
import org.apache.turbine.modules.screens.RawScreen;
import org.apache.turbine.util.RunData;
public class ImageScreen
extends RawScreen
{
protected Log log = LogFactory.getLog(this.getClass());
public String getContentType(RunData data)
{
return "image/gif";
}
protected void doOutput(RunData data)
throws Exception
{
HttpServletResponse response = data.getResponse();
ImageModel imageModel = ImageModel.getModel(data);
ApacheUser user = (ApacheUser) imageModel.getUser();
byte [] img = user.getImage();
OutputStream os = response.getOutputStream();
if (img != null && img.length > 0)
{
os.write(img);
}
os.flush();
}
}
--- cut ---
This outputs a GIF (which is available as a byte array from
user.getImage()) through a RawScreen. This is actual code from the
ApacheFaces application which made 2nd prize at the Derby Contest @
ApacheCon.
I will polish this application some more and then it will go into the
Turbine repository as an example application for Turbine 2.3.x
programming.
Regards
Henning
--
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen INTERMETA GmbH
hps@intermeta.de +49 9131 50 654 0 http://www.intermeta.de/
RedHat Certified Engineer -- Jakarta Turbine Development -- hero for hire
Linux, Java, perl, Solaris -- Consulting, Training, Development
What is more important to you...
[ ] Product Security
or [ ] Quality of Sales and Marketing Support
-- actual question from a Microsoft customer survey
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
Re: generating a binary download
Posted by Vaucher Stephane <va...@minmax.ca>.
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q260519
there is a problem in IE5.5
http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q279667
sv
On Thu, 25 Nov 2004, Ilan Azbel wrote:
> I sent a similar message to the velocity mailing list but was informed that
> this would probably be a better list to email with my question:
>
> Hello,
>
> I would like a servlet to return a binary file and thereby instruct the
> browser
> not to display it, but rather to download it. That is, ask the user if they
> would like to "Open" or "Save" the file.
>
> I would like to do this without any redirecting statements - so as soon as a
> user requests a certain servlet, the corresponding java creates some type
> of binary data, and the browser immediately asks whether to open or save
> this data.
>
> I already have an existing Turbine/Velocity application running on the same
> server and I would like to use the database connections that turbine has
> already make for the current web application. I don't even have any idea of
> where to start with this, help?!?!
>
>
> Thanks
> Ilan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
RE: generating a binary download
Posted by David Demner <tu...@demner.com>.
Hi Ilan,
Someone posted a solution to this a while ago. It's under the unlikely
subject 'communication betweeen turbine servlets and jfreechart' so it took
a while to track down.
You can get it in the archive at:
http://www.mail-archive.com/turbine-user@jakarta.apache.org/msg14554.html
Good luck,
David
-----Original Message-----
From: Ilan Azbel [mailto:iazbel@mdio.net]
Sent: Thursday November 25, 2004 5:52 AM
To: Turbine-User
Subject: generating a binary download
I sent a similar message to the velocity mailing list but was informed that
this would probably be a better list to email with my question:
Hello,
I would like a servlet to return a binary file and thereby instruct the
browser
not to display it, but rather to download it. That is, ask the user if they
would like to "Open" or "Save" the file.
I would like to do this without any redirecting statements - so as soon as a
user requests a certain servlet, the corresponding java creates some type
of binary data, and the browser immediately asks whether to open or save
this data.
I already have an existing Turbine/Velocity application running on the same
server and I would like to use the database connections that turbine has
already make for the current web application. I don't even have any idea of
where to start with this, help?!?!
Thanks
Ilan
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org