wood burning stoves*
The moose likes Servlets and the fly likes problem with utf-8 encoding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "problem with utf-8 encoding" Watch "problem with utf-8 encoding" New topic
Author

problem with utf-8 encoding

Irakli Bliadze
Greenhorn

Joined: Dec 09, 2011
Posts: 17
i deploying application on tomcat server and i use to download file servlet wich calling procedure is

its working fine but, its not returning correct file name when i have non latin alphabet
but when i adding this "response.setCharacterEncoding("UTF-8");"
i getting error "Exception Details: java.nio.charset.MalformedInputException
Input length = 1"
anybody can help me? why i getting error when i adding encodding utf-8?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

Can you please UseCodeTags next time? It makes your code so much easier to read.

This isn't the fix to your problem, but you have a bug in your file reading code:
Irakli Bliadze wrote:

That check should be > -1 instead of > 0. 0 is a valid return value of InputStream.read, it just means there's no data available right now. There is only one value that indicates there is no more data and that's -1.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Irakli Bliadze
Greenhorn

Joined: Dec 09, 2011
Posts: 17
thanks for advice about codeTag i didn't knew it.
and put >-1 instead of >0 but result is same error
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: problem with utf-8 encoding
 
Similar Threads
bytearray image decoding
A problem with servlet file transfer
error locating file in servlet
IllegalStateException after canceling file downloading.
Opening a PDF