vendredi 6 mars 2015

Printing UTF8 extended characters in servlet ( Solved) [on hold]



I try this code and it works very well:



package code;



public class TestClass
{
public static String myName="محمد mohammed";


public static String getMyName()
{
return myName;
}
public static void main(String[] args)
{
System.out.println(getMyName());
}

}


and I get this result :



محمد mohammed



But when I try to call from servlet in same package and project :



protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
{

...
System.out.println(TestClass.getMyName());
...
}// END DO GET


I got this result:



???? mohammed



Moreover, I tried to print directly from the servlet and I got '?' for any Arabic letter.


Note: In two files I use : UTF-8


**



It is solved by changing server encoding. see below:



**



Go to (if use Eclipse): 1- Servers. 2- open the server. 3- find : open lunch configuration then open it. 4- Go to Common. 5- Change Encoding.





Aucun commentaire:

Enregistrer un commentaire