Saving JSP as UTF-8 in NetBeans

I have some jsp files from other developers, and now you need to work with them. When I add any UTF-8 char to a document and want to save the document, NetBeans automatically offers me to save to ISO-8859-1.

I actually get this message from NetBeans:

The .jsp index contains characters that are likely to be corrupted during conversion to the ISO-8859-1 character set. Do you want to save the file using this character set? (Well no)

NB did not offer me another option, like saving a file as UTF-8 (as it should already be written).

I do not know how to save these jsp files in the character set in which they are already written.

And do not tell me that changing the contents of the file itself (which is inefficient due to the inclusion of headers, etc. from other files) is the only way ...

http://forums.netbeans.org/topic8750.html

+7
source share
1 answer

At first; don't forget to look at this line at the top:

<%@page contentType="text/html" pageEncoding="UTF-8"%> 

Secondly, there is a configuration file in the NetBeans folder. There should be a line:

 netbeans_default_options="-J-Xms32m -J-Xmx128m -J-XX:PermSize=32m -J-XX:MaxPermSize=160m -J-Xverify:none -J-Dapple.laf.useScreenMenuBar=true" 

Add this to the end of the line:

 -J-Dfile.encoding=UTF-8 

Thirdly:

NetBeans implements coding customization for the project.

To change the language encoding for a project:

  • Right-click the project node in the Projects windows and select Properties.
  • In the Sources section, select an encoding value from the Encoding drop-down list.

Encoding affects at least:

 * how non-ASCII characters are displayed in the editor window when you open files * Java file compilation of sources containing non-ASCII identifiers, string literals, or comments * textual search for international characters over the project 

Starting with NetBeans IDE 6.8, you can also specify the encoding that will be used at runtime. For example, this can be useful when the encoding for the operating system on which the application is running is different from your design encoding.

To specify the encoding to be used at runtime:

  • In the Files window for your project, open nbproject> private> private.properties
  • Add the following line to the private.properties file and save the changes:

runtime.encoding = <encoding>

This encoding will override the encoding setting for your project and will be used when the application starts.

In general

 *.properties files always use ISO-8859-1 encoding plus \uXXXX escapes. (International characters will be displayed natively in the editor but stored as an escape on disk.) *.xml files and some *.html files can specify their own encodings, regardless of the project encoding. For such files, the IDE editor ignores the project encoding. 

It can help you.

Sources for my answer that I used:

Link1: http://forums.netbeans.org/topic33.html

Link 2: http://wiki.netbeans.org/FaqI18nProjectEncoding

+16
source

All Articles