Changing Eclipse Default Encoding to UTF-8 for JSP files
Join the DZone community and get the full member experience.
Join For FreeTry creating a new JSP file in your Eclipse and you’ll notice that the JSP page directive will have encoding something like:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
But for a better I18N and L10N support, it is recommended to follow UTF-8 encoding where ever possible. So, how do we change the default JSP file encoding to UTF-8 in eclipse? Simple. Just do these things:
- In Eclipse, go to Windows -> Preferences -> Web -> JSP Files
- Select UTF-8 encoding from the Encoding dropdown box there.
That’s it! And if you wonder how this change works, you can very well see that. In the same Preferences window, go to this location: Preferences -> Web -> JSP Files -> Editor -> Templates. Then in the right hand side, you’ll see a list of templates defined for JSP files. And in a new JSP file template, you can see this code:
<%@ page language="java" contentType="text/html; charset=${encoding}" pageEncoding="${encoding}"%>
Here as you might have guessed, the ${encoding} will be replaced by whatever we set in the above step.
The same method can be used to change the default encoding type for other file types too (css, html).
From http://veerasundar.com/blog/2010/12/changing-eclipse-default-encoding-to-utf-8-for-jsp-files/
Opinions expressed by DZone contributors are their own.
Comments