0

In the context of a Wicket component using JavaScript, I'm sending the following string back to Wicket :

"FICHIERfichier&é'(-è_çà)=~#{[`^@]}^$ù,;!¨£%µ§êë-+¤.0²123456789.pdf"

I have to escape() this in JavaScript because otherwise Wicket interprets the ampersand as a parameter delimiter and chops the string into multiple parameters.

However, this is what I get on the Wicket side of things :

"FICHIERfichier&�'(-�_��)=~#{[`^@]}^$�,;!��%����- �.0�123456789.pdf"

Any ideas ? I've tried many unescape/decode methods to no avail...

Many Thanks !

1 Answer 1

0

It seems the character encoding your application uses does not support some of the sent characters.

Make sure you use a good charset in Wicket's RequestCycleSettings. By default it is UTF-8, but your application may have changed it.

In addition if you use some old version of a Servlet container then you may need to use a Servlet Filter around Wicket Filter that sets the character encoding on the HttpServletRequest. A quick googling for "Servlet filter character encoding" gives this good example: https://stackoverflow.com/a/11100412/497381.

public class CustomCharacterEncodingFilter implements Filter {

  public void init(FilterConfig config) throws ServletException {
  }

  public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) 
                                                   throws IOException, ServletException {
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
    chain.doFilter(request, response);
  }

  public void destroy() {
  }

}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.