0

I am developing a web application using Primefaces JSF using the XHTML page in that I am not able to retrieve the Arabic data from <p:inputText> tag to the getter and setter method it is showing as ???? ???? while printing in the console and the same is storing in the MySQL database.

Things that I have tried.

  1. Written this encoding in the filter

    @WebFilter("/*")
    public class CharacterEncodingFilter implements Filter {
        @Override
        public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException {
            req.setCharacterEncoding("UTF-8");
            resp.setCharacterEncoding("UTF-8");
            chain.doFilter(req, resp);
        }
    
  2. Mentioned the contentType and Encoding in the <f:view> tag

  3. added this in the glassfish-web.xml <parameter-encoding default-charset="UTF-8"/>

Nothing works for me.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Ramesh T
  • 1
  • 1
  • 1
    I don't see any jsf nor primefaces in the question. [mcve] please – Kukeltje Jan 10 '20 at 06:40
  • 1
    Edit your question with code and make it a [mcve] – Kukeltje Jan 10 '20 at 07:05
  • As to console, which IDE are you using? Is it already configured to use UTF-8 in console? See also https://stackoverflow.com/q/13452324. If that solves your problem, then https://stackoverflow.com/q/13451061 is your another duplicate for MySQL. – BalusC Jan 10 '20 at 09:13
  • I am using NetBeans and it is already configured to UTF-8 then also it is showing the same error – Ramesh T Jan 10 '20 at 09:19
  • The sympoms suggest it is not. If Netbeans was really configured to use UTF-8 and the cause of the problem was indeed in JSF/PrimeFaces, then you would for an input of `اَلْعَرَبِيَّةُ‎` have seen something like `اÙÙÙØ¹ÙØ±ÙØ¨ÙÙÙÙØ©Ùâ` instead of `????????????????`. But you're still seeing question marks, so Netbeans is still wrongly configured .. Let's ask another question to exclude one and other, when you redisplay the input values in the same JSF page (without console/MySQL), what exactly do you see? Just use ``. – BalusC Jan 10 '20 at 09:45
  • Thanks a lot, BalusC its worked, stackoverflow.com/q/13451061 this one I followed which you gave in before comment and now the Arabic data is storing in the database as the same Arabic text, but when I print in the console it is showing as again '?????' – Ramesh T Jan 10 '20 at 10:20
  • You need to configure Netbeans to use UTF-8 in console. If that still doesn't work then problem is still not related to JSF/PrimeFaces/MySQL but to Netbeans itself. – BalusC Jan 10 '20 at 15:25

0 Answers0