-
Apache Tomcat Question
I have Apache Tomcat installed in my Server. One of my web page have a link
yo download a text file. But instead of display the window to save it on
the disk or run from site, it automatically downloaded into the web browser.
How can configure the Server to display the "SAVE AS" window. Thanks in advance.
-
Re: Apache Tomcat Question
"Jose Rodz" <rodriguezj.orion@afwtf.navy.mil> wrote:
>
>I have Apache Tomcat installed in my Server. One of my web page have a link
>yo download a text file. But instead of display the window to save it on
>the disk or run from site, it automatically downloaded into the web browser.
>How can configure the Server to display the "SAVE AS" window. Thanks in
advance.
The browser is 'helping' you out. I think what you will need to do is serve
up the file via a servlet (or JSP if you must) and use a different mime type.
There may be something that you can set in the HTML but that is an HTML
question not Java. Check out one of those groups.
-
Re: Apache Tomcat Question
Jose,
I dont think that you can set that up on the server side. The "Save As"
window is configured on the client side. What you can do to force the window
to show is either save the file as a mime-type that the browser doesnt support
(ie. like a zip file ). Hope this helps, Joe
"Jose Rodz" <rodriguezj.orion@afwtf.navy.mil> wrote:
>
>I have Apache Tomcat installed in my Server. One of my web page have a link
>yo download a text file. But instead of display the window to save it on
>the disk or run from site, it automatically downloaded into the web browser.
>How can configure the Server to display the "SAVE AS" window. Thanks in
advance.
-
Re: Apache Tomcat Question
I found the web link for the complete article doing a Google search:
http://www.fawcette.com/javapro/2002...ervlets_03_08/
David Stevenson
"David Stevenson" <drs2@frontiernet.net> wrote in message
news:3d13db4c$1@10.1.10.29...
>
> "Jose Rodz" <rodriguezj.orion@afwtf.navy.mil> wrote:
> >
> >I have Apache Tomcat installed in my Server. One of my web page have a
link
> >yo download a text file. But instead of display the window to save it on
> >the disk or run from site, it automatically downloaded into the web
browser.
> >How can configure the Server to display the "SAVE AS" window. Thanks in
> advance.
>
-
Re: Apache Tomcat Question
"Jose Rodz" <rodriguezj.orion@afwtf.navy.mil> wrote:
>
>I have Apache Tomcat installed in my Server. One of my web page have a link
>yo download a text file. But instead of display the window to save it on
>the disk or run from site, it automatically downloaded into the web browser.
>How can configure the Server to display the "SAVE AS" window. Thanks in
advance.
I found this article in my e-mail, but I don't know the web address of the
original article:
Send Files to Browser Clients the Right Way
You want a browser client to download a file, so just link to it, right?
Wrong.
by Budi Kurniawan
Posted March 13, 2002
Web programmers often ask how to send a file to the browser and force the
browser to display the Save dialog box. Of course, the simplest solution
is to provide a link to the file. However, this solution has two disadvantages.
...
With that out of the way, here's what you have to do in your code. First,
set the response's content type to APPLICATION/OCTET-STREAM. This value is
not case-sensitive. Then, add an HTTP response header named Content-Disposition
and give it this value:
attachment; filename=theFileName
Where "theFileName" is the default name for the file that appears on the
File Download dialog box. This is normally the same name as the file, but
does not need to be.
Finally, this JSP page demonstrates how to send a file to the user's browser:
<%
// fetch the file
String filename = "companySecret.txt";
String filepath = "C:\\";
response.setContentType(
"APPLICATION/OCTET-STREAM");
response.setHeader("Content-Disposition",
"attachment; filename=\""
+ filename + "\"");
java.io.FileInputStream fileInputStream =
new java.io.FileInputStream(filepath
+ filename);
int i;
while ((i=fileInputStream.read()) != -1) {
out.write(i);
}
fileInputStream.close();
out.close();
%>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks