You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Roberto Rios <ro...@innovaction.com.br> on 2005/06/28 15:49:06 UTC
Problems serving files to download
Hi,
I have a tomcat 4.1.31 (j2sdk1.4.2_08) running in a linux rh9 box. It's
a fresh install.
I'm from Brazil, so I've configured my linux to use pt_BR.ISO-8859-1. If
I type locale, everything is ok.
My CATALINA_OPTS has the "-Dfile.encoding=ISO-8859-1"
I have no problems with my applications. Everithing works fine. All my
pages are compiled fine, my servlets work fine, etc...
But, if I try to serve files to download, and this files had special
characters like çãí....etc, when I click the file name (that is
displayed right), I receive the 404 HTTP error.
For instance: using vi, I created a file named "acentuação.txt" inside
the tomcat-docs directory. When I try to access this file, it's name is
encoded to "acentua%C3%A7%C3%A3o.txt" (the address shows
<http://localhost/tomcat-docs/acentua%C3%A7%C3%A3o.txt>
http://localhost/tomcat-docs/acentua%C3%A7%C3%A3o.txt), and after that I
can't access it. I tryed to use Firefox (1.0.4) and IE 6, but I got the
same problem
How do I manage this? Who encoded the name?
TIA,
Bob
RES: Problems serving files to download
Posted by Roberto Rios <ro...@innovaction.com.br>.
Hi,
Thanks for replying. No, I'm not using servlets to read the files.
The files are being served directly by tomcat. I have configured tomcat
to allow directory linstings, so I can see the files in the directory
and click on it directly.
By the way, the same problem occurs with files that have spaces in their
names. If I try to download a file named "this is an example.txt" the
same error occurs. The file name is encoded to
"this%20is%20an%20example.txt" and after that I'm not able to download
it.
Using your sugestion, I created a small jsp with the following code:
<%
String s = java.net.URLDecoder.decode(
"http://localhost/tomcat-docs/acentua%C3%A7%C3%A3o.txt", "UTF-8" );
Reponse.sendRedirect(s);
%>
It works fine. I was able to download the file. The problem is that as I
said, the files are being served directly, and I am trying to understand
why tomcat isn't able to decode the url properly... Well, I'm not sure
if this is or not a tomcat misconfiguration problem...
Thanks again,
Bob
-----Mensagem original-----
De: Robert Harper [mailto:robert@iat-cti.com]
Enviada em: terça-feira, 28 de junho de 2005 11:12
Para: 'Tomcat Users List'; roberto.rios@innovaction.com.br
Assunto: RE: Problems serving files to download
Try the following if you are trying to read the following in a servlet:
String s = java.net.URLDecoder.decode(
"http://localhost/tomcat-docs/acentua%C3%A7%C3%A3o.txt", "UTF-8" );
You can read the file and write it out to the response stream. Since
this is a text file it will be displayed in the browser window. The user
may then save the file from the browser.
Robert S. Harper
Information Access Technology, Inc.
-----Original Message-----
From: Roberto Rios [mailto:roberto.rios@innovaction.com.br]
Sent: Tuesday, June 28, 2005 7:49 AM
To: 'Tomcat Users List'
Subject: Problems serving files to download
Hi,
I have a tomcat 4.1.31 (j2sdk1.4.2_08) running in a linux rh9 box. It's
a fresh install.
I'm from Brazil, so I've configured my linux to use pt_BR.ISO-8859-1. If
I type locale, everything is ok.
My CATALINA_OPTS has the "-Dfile.encoding=ISO-8859-1"
I have no problems with my applications. Everithing works fine. All my
pages are compiled fine, my servlets work fine, etc...
But, if I try to serve files to download, and this files had special
characters like çãí....etc, when I click the file name (that is
displayed right), I receive the 404 HTTP error.
For instance: using vi, I created a file named "acentuação.txt" inside
the tomcat-docs directory. When I try to access this file, it's name is
encoded to "acentua%C3%A7%C3%A3o.txt" (the address shows
<http://localhost/tomcat-docs/acentua%C3%A7%C3%A3o.txt>
http://localhost/tomcat-docs/acentua%C3%A7%C3%A3o.txt), and after that I
can't access it. I tryed to use Firefox (1.0.4) and IE 6, but I got the
same problem
How do I manage this? Who encoded the name?
TIA,
Bob
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
RE: Problems serving files to download
Posted by Robert Harper <ro...@iat-cti.com>.
Try the following if you are trying to read the following in a servlet:
String s = java.net.URLDecoder.decode(
"http://localhost/tomcat-docs/acentua%C3%A7%C3%A3o.txt", "UTF-8" );
You can read the file and write it out to the response stream. Since this is
a text file it will be displayed in the browser window. The user may then
save the file from the browser.
Robert S. Harper
Information Access Technology, Inc.
-----Original Message-----
From: Roberto Rios [mailto:roberto.rios@innovaction.com.br]
Sent: Tuesday, June 28, 2005 7:49 AM
To: 'Tomcat Users List'
Subject: Problems serving files to download
Hi,
I have a tomcat 4.1.31 (j2sdk1.4.2_08) running in a linux rh9 box. It's
a fresh install.
I'm from Brazil, so I've configured my linux to use pt_BR.ISO-8859-1. If
I type locale, everything is ok.
My CATALINA_OPTS has the "-Dfile.encoding=ISO-8859-1"
I have no problems with my applications. Everithing works fine. All my
pages are compiled fine, my servlets work fine, etc...
But, if I try to serve files to download, and this files had special
characters like çãí....etc, when I click the file name (that is
displayed right), I receive the 404 HTTP error.
For instance: using vi, I created a file named "acentuação.txt" inside
the tomcat-docs directory. When I try to access this file, it's name is
encoded to "acentua%C3%A7%C3%A3o.txt" (the address shows
<http://localhost/tomcat-docs/acentua%C3%A7%C3%A3o.txt>
http://localhost/tomcat-docs/acentua%C3%A7%C3%A3o.txt), and after that I
can't access it. I tryed to use Firefox (1.0.4) and IE 6, but I got the
same problem
How do I manage this? Who encoded the name?
TIA,
Bob
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org