?
Solved

File Upload

Posted on 2003-03-05
29
Medium Priority
?
790 Views
Last Modified: 2010-04-01
Hi

I got a problem when I try to upload a file using this UploadBean http://www.javazoom.net/jzservlets/uploadbean/documentation/index.html. The problem is that it is impossible to upload files with the danish characters "æøå" in Linux!

It works well under Windows but not in Linux.

Hope someone can help me.

Jan
0
Comment
Question by:COOLJMA
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 13
  • 8
  • 5
  • +2
29 Comments
 
LVL 4

Expert Comment

by:thanassis
ID: 8072089
I think you are in trouble.
Have you installed danish fonts in your Linux machine?
0
 
LVL 14

Accepted Solution

by:
kennethxu earned 200 total points
ID: 8072714
it's nothing to do with the font, rather the characterset your linux supports.

do you mean the danish characters in file name or file content?

can you please post the full stacktrace of the error you get?

thanks.
0
 

Author Comment

by:COOLJMA
ID: 8072830
The characters works well under Linux but not when I use the UploadBean. I don't get an error, it just upload the file as for instance æøå.txt to ???.txt. There after its not possible to download the file again, even i you write ???.txt.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:kennethxu
ID: 8073976
that's character encoding issue. which encoding system are you using utf-8?
0
 
LVL 19

Assisted Solution

by:cheekycj
cheekycj earned 200 total points
ID: 8074298
why is character encoding an issue for binary file transfers?

encoding is only an issue if you are dealing with ascii streams or strings etc.

CJ
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8074717
CJ, COOLJMA have problem with his file name.
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 8074751
oh, I thought it was the content.

yes that is the client machine and the server machine's issue.

The client machine must support the character set and so does the server machine to store it.

CJ
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8074847
>> The client machine must support the character set and so does the server machine to store it.
not necessary, it is possible to use different character set as long as you can convert one to the other.
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 8074987
true but I am working on a project where conversion btw Unicode and UTF-8 charactersets is causing big problems so I am not sure if thats something you want to leave to conversion anymore.

CJ
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8075228
hmmm, what do you unicode to utf-8, utf-8 is one of unicode encoding. do you mean utf-16 to utf-8?
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 8075287
unicode 2.0 to utf-8.

the conversion has problems with high ascii characters.  I have a question open about it in the java topic area.

CJ
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8075633
I used to be in java topic area, but just don't have enough time to run on two topics :(
I can have a look at it if you post the link.
0
 

Author Comment

by:COOLJMA
ID: 8082203
Your are probably on the right target about the encoding because the same problem raise if you have to print out something from a database. The characters is saved right in the database but is not printed right if it comes from the database. But for some weird reason it is possible to write <%="æøå"%>. And this works... the used characterset on the Linux mashine is not UTF but ISO8859-1.

Jan
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8082701
can you show us the code of upload and download?
0
 

Author Comment

by:COOLJMA
ID: 8083107
Yes it is the default from JavaZoom on http://www.javazoom.net/jzservlets/uploadbean/uploadbean.html#download. The version is 1.3...and the JSP file is SimpleUpload.jsp
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8085523
right, but

1. the default was "D:/uploads" for upload dir, you must have change it to work with linux.

2. what about your download page?
0
 

Author Comment

by:COOLJMA
ID: 8089702
I changed it to "/var/tomcat4/webapps/ROOT/cooljma/doc".

On my download page I just write..
<a href="doc/filename">filename</a>

But it is pretty sure that the problem is JAVA or the encoding, because if you make a System.out.println("æøå"); you will get a wrong result also in Windows. In Windows the way to solve this is by adding the parameter -Dfile.encoding=Cp850 but I have no idea how to set this by default or how to set this in Linux, and expecially not which encoding that works, because -Dfile.encoding=ISO8859-1 do not work, either do -Dfile.encoding=Cp850. Therefore im pretty lost.

Jan
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8090044
I didn't have cp850 installed, but when I tried gb2313 (chinese coding), uploadbean changed every chinese character into &#xxxx; in filename. which works fine when i download because browser will translate it back to chinese character. strange that you are getting something different.
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8090103
not so sure but can you try:

UploadFile file = (UploadFile) mrequest.getFiles().get( "uplaodfile" );
file.setFileName( new String( file.getFileName().getBytes("ISO8859-1"), "Cp850" );

0
 

Author Comment

by:COOLJMA
ID: 8093442
Nice try kennethxu.. you have to switch ao in uploadfile and there are missing a ")" in the last line.. but this didn't work either.. It says null pointer exception and made need for a restart of tomcat... Because it keep saying that even if I removed the 2 linies again.

Jan
0
 

Author Comment

by:COOLJMA
ID: 8093451
About the Chinese coding, this might caused by the fact that this language are supported. If I need to download the file &aelig;&oslash;&aring;.txt the filename i have to type is %3F%3F%3F.txt

Jan
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8094937
sorry for the bad try :) i was not at my PC when I post, so didn't tested myself.

the first line of code is not needed, because SimpleUplaod.jsp already have it. I added the 2nd line to my code and purposely prefix filename with "XXXXX".

file.setFileName( "XXXXX" + new String( file.getFileName().getBytes("ISO8859-1"), "Cp850" ) );

it worked for me, and files in dir does contain "XXXXX", that mean you can rename and/or change encoding in this way.

2ndly, in jsp page you'll need to
<%@page contentType="text/html; charset=IBM850" encoding="Cp850"%>
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8094946
sorry I didn't try the characters you mentioned, because I don't know how to enter them :(
0
 

Author Comment

by:COOLJMA
ID: 8097234
Kennethxu, did you test this in Linux or Windows?? I have found out that it might be the JRE that causes the problem because my filesystem is ISO8859-1 and my file-encoding in JRE is ANSI_X3.4-1968. I found this by running this code.

public class TestEncoding {
     public static void main(String[] args) {
     System.out.print("File.encoding: ");
     System.out.println(System.getProperty("file.encoding"));
     }
}

It seem that i'm not the only one with the problem.
http://forum.java.sun.com/thread.jsp?thread=315993&forum=16&message=14

http://developer.java.sun.com/developer/bugParade/bugs/4803820.html

Jan
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8141007
How is this going? my LANG=en_US.UTF-8 in linux, I can only tested Chinese, it's been converted to &#xxxx; and works fine.

you can try to use java -Dfine.encoding=ISO8859-1 when you start you server, or set LANG=???.
0
 

Author Comment

by:COOLJMA
ID: 8141955
I already tried this but this is not working... I believe that it is because that Chinese is supported and Danish is not.
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 9228891
any updates here?

CJ
0
 
LVL 35

Expert Comment

by:girionis
ID: 10040939
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Split points between kennethxu and cheekycj

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

girionis
EE Cleanup Volunteer
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
"Any files you do not have backed up in at least two [other] places are files you do not care about."
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question