Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Ayden Smith   on Nov 11 In Java Category.

  
Question Answered By: Sonya Flores   on Nov 11

In this case you could save your pages as utf-8 unicode  (Codepage)
Or
Using Filtering Pattern to do this in all across your project
I write this for you to use it and joy it.


public class EncodingFilter implements Filter {

private final String targetEncoding = "UTF-8";

public void init(FilterConfig config) throws ServletException {
}

public void destroy() {
}

public void doFilter(ServletRequest srequest, ServletResponse sresponse, FilterChain chain)
throws IOException, ServletException {

HttpServletRequest request = (HttpServletRequest) srequest;
request.setCharacterEncoding(targetEncoding);
chain.doFilter(srequest, sresponse);
}
}


and then you should declare this line in web.xml of your project

<filter>
<filter-name>EncodingFilter</filter-name>
<filter-class>com.basamadco.opxi.manager.filter.EncodingFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>EncodingFilter</filter-name>
<url-pattern>*.htm</url-pattern> <!-- your pages extentions like html or jsp or jsf and so on-->
</filter-mapping>

Share: 

 

This Question has 1 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Unicode Problem Or get search suggestion and latest updates.


Tagged: