Unicode File movement from Windows to Unix adding Special Characters

Discussion in 'Java' started by ragz_82, Feb 8, 2011.

  1. ragz_82

    ragz_82

    Joined:
    Apr 8, 2009
    Messages:
    9
    Hi,
    In our application a Unicode file with German and Japanese characters is submitted, which is moved to a Unix directory by using the MultipartRequest JAVA API. Later Oracle PL/SQL processes the file and makes entries in the database.

    We have observed that this load is failing since the file is having some special characters when it is getting transferred to Unix. The file is untouched if it contains only English characters. To confirm this we created a file directly in Unix containing Ger/Jap chars and called the Oracle St Proc and it worked fine. When this same file was moved back to Windows using WinSCP, the file was different again.

    Hence overall it looks like Unicode file movement between Windows and Unix changes the file in someway for some reason. Please let me know if any JAVA API can avoid this issue.

    I scanned the Net for close to a week but couldn't find anything related. Any help will be greatly appreciated.

    If we cant find any solution, we are considering using POI so that JAVA can directly update the Database.

    Rgds,
    Raghu
     
    ragz_82, Feb 8, 2011
    #1
    1. Advertising

  2. ragz_82

    ragz_82

    Joined:
    Apr 8, 2009
    Messages:
    9
    I read that MultipartRequest and Apache FileUpload are the two common APIs used to perform file uploads in JAVA. Hence I tried also with the Apache API, but the result was exactly the same.

    Hence I suspect that some encoding related setting is missing in either the JSP or the Servlet code. Below is my code snippet. Please suggest.

    -- JSP
    <meta http-equiv="Content-Language" content="en-us">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="Expires" content="Tue, 20 Aug 1996 14:25:27 GMT">
    <meta http-equiv="Cache-Control" content="no-cache">

    <script language="javascript" src="../js/stylesheet.js"></script>
    <script language="JavaScript" src="../js/datePicker.js"></script>
    <script language="JavaScript" src="../js/validate.js"></script>

    </head>

    <body>

    <form ENCTYPE="multipart/form-data" name="frmUpload" method="POST" action="<%= request.getContextPath() %>/servlet/TestServlet">

    Select File: <input type="file" name="file" size="30">
    <input value="Upload" name="cmdUpload" type="submit">

    -- Servlet
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    {
    request.setCharacterEncoding("UTF-8");

    MultipartRequest multi = new MultipartRequest(request,
    "/tmp",
    20000000,
    "UTF-8");
    }
     
    ragz_82, Feb 9, 2011
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stefan Mueller
    Replies:
    3
    Views:
    33,037
    Stefan Mueller
    Jul 23, 2006
  2. xah@xahlee.org

    Re: Meta-Characters, Special Characters

    xah@xahlee.org, May 30, 2007, in forum: Java
    Replies:
    2
    Views:
    1,095
    Ingo Menger
    May 31, 2007
  3. rvino
    Replies:
    0
    Views:
    4,660
    rvino
    Aug 14, 2007
  4. Grzegorz ¦liwiñski
    Replies:
    2
    Views:
    966
    Grzegorz ¦liwiñski
    Jan 19, 2011
  5. majna
    Replies:
    4
    Views:
    676
    Thomas 'PointedEars' Lahn
    Sep 19, 2007
Loading...

Share This Page