Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Changing Eclipse Default Encoding to UTF-8 for JSP files

DZone's Guide to

Changing Eclipse Default Encoding to UTF-8 for JSP files

· Java Zone ·
Free Resource

Verify, standardize, and correct the Big 4 + more– name, email, phone and global addresses – try our Data Quality APIs now at Melissa Developer Portal!

Try 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:

  1. In Eclipse, go to Windows -> Preferences -> Web -> JSP Files
  2. 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/

Developers! Quickly and easily gain access to the tools and information you need! Explore, test and combine our data quality APIs at Melissa Developer Portal – home to tools that save time and boost revenue. Our APIs verify, standardize, and correct the Big 4 + more – name, email, phone and global addresses – to ensure accurate delivery, prevent blacklisting and identify risks in real-time.

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}