0

I am having an issue with HTML textarea in jsp form. The string(.....) got passed from jsp form(using javascript call) to WebLogic action correctly. However, when it is saved in Oracle, it turns into question mark (?????). This problem only happens in IE, Chrome works fine. I think it has to do with the encoding. I need some suggestions to fix this problem.

Thanks in advance!

I have tried the followings but the problem is still there:

  1. modify weblogic.xml
<charset-params>
  <input-charset>
    <resource-path>/*</resource-path>
    <java-charset-name>UTF-8</java-charset-name>
  </input-charset>
</charset-params> 
  1. change startWebLogic.cmd
-Dfile.encoding=UTF-8 -Doracle.jdbc.defaultNChar=true
  1. update connection string in WebLogic server
useUnicode=true&characterEncoding=UTF-8

Update:

current code

 $('.myid').on('keyup change', function(){
      $.post('action.do', {idx: $(this).attr('id'), notes: $(this).val(), 
           rand: Math.random()}, function( resp ){
            if ( resp == null || resp.indexOf("success") == -1 ) {
                alert("Failed to save notes!");
            }
     })
})

here is action.do

        request.setCharacterEncoding("UTF-8");

        // save notes with right content from user's input (...............)
        // however after refreshing the page, notes turn into ???????
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
                out.println( message );
        } finally {
            out.flush();
            out.close();
        }

Oracle: Would this be a problem?

NLS_CHARACTERSET    US7ASCII

Thanks

user1874435
  • 161
  • 13
  • For testing purposes, I suggest you try to pass the value from the string variable instead of HTML Textarea control. See whether values get stored properly or not. It can help to narrow down the issue. Further, try to debug the code execution step by step and try to check the passed value at each step may help to find problematic code. You can also try to select the encoding manually from the `View tab-> Encoding-> Unicode(UTF-8)`. After that try to test the issue. – Deepak-MSFT Jan 27 '21 at 05:08
  • I have added the update. $(this).val() get the content of textarea is not working correctly. I have changed IE to use Unicode(UTF-8) – user1874435 Jan 27 '21 at 22:08
  • I try to make a test with the `$(this).val()` on my end and found that it is working fine. Please see my test result [here](https://imgur.com/a/7FeYgsl). I suggest you try to provide a proper code example that can help us to reproduce the issue. It may give some idea about the cause for this issue. – Deepak-MSFT Jan 28 '21 at 01:43
  • again, this encoding problem happens when the string send to Weblogic, which uses oracle datasource. It is weird that IE causes this problem. I have followed this https://stackoverflow.com/questions/33941751/html-form-does-not-send-utf-8-format-inputs - add filter, set encoding on request, and set -Dfile.encoding. It is still not working. – user1874435 Jan 28 '21 at 05:17
  • On my end, I am not available with the Weblogic and oracle data source. did you check the request header after changing the encoding to UTF-8? If there is any simple way to reproduce the issue then you can inform me. I can try to make a test with it to check for the issue. Thanks for your understanding. – Deepak-MSFT Jan 29 '21 at 07:58

0 Answers0