0

I have a textarea name remarks. When i enter ‘ this special character in textarea at the backend servlet I'm getting that value like ?(question mark) special character remarks============???????????????????????????????????????? and getting the below expetion

java.sql.SQLException: Incorrect string value: '\xC2\x91\xC2\x91\xC2\x91...' for column 'remarks' at row 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1078)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4190)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4122)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2570)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2731)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2818)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2157)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2460)

I tried the below regular expression but the exception is not solved.

     if(remarks.matches("^[?]")){
                errors.put("remarks", "Invalid remarks!");
            }
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Asha
  • 115
  • 1
  • 13
  • why dont you restrict users to enter special character in jsp page itself. As per your current case, you allow user to do something and in backend you are restricting that then what is the use of allowing special charcter – SpringLearner Jun 16 '16 at 09:03
  • try "\?", and you should restrict the input on client side by using javascript. – Jswq Jun 16 '16 at 09:03
  • sometimes client side validations may fail. Thats why I'm using server side validations@SpringLearner – Asha Jun 16 '16 at 09:09
  • @Asha *sometimes client side validations may fail.* I dont think so – SpringLearner Jun 16 '16 at 09:13

0 Answers0