Search code examples
javamysqlstruts2tomcat7jquery-ajaxq

Struts2 - pass enye character from jsp to struts 2 action class properly


I have a webapp built using Struts2, with Tomcat 7 as application server and MySQL database as backend. Now i pass some string from my jsp file using jquery ajax but this string contains special characters (ñ - enye). When i alert it before passing to the class via jquery ajax, it displays fine but when i receive it in the java class, it displays like ñ . I need the string to be as exact as possible as i am querying the mysql database with an entry similar to the string.

All jsp pages have <%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%> and <meta http-equiv="content-type" content="text/html; charset=utf-8"/> in head as well as the jquery contentType contentType: 'application/json; charset=utf-8'.

What could be the possible solution to this? Thanks for your reply. Here are the screenshots by the way. Thanks for your help :)

alert from jsp system.out.println on console the database entry that needs to be matched


Solution

  • Luckily found the answer within StackOverflow. Thanks guys, you're the best :)

    How to determine if a String contains invalid encoded characters