Invalid character encoding in JSP files encoded as UTF-8

Source: Internet
Author: User
When we use include to include JSP files, we find that there are redundant blank lines on the final generated page, and there is a character that cannot be displayed in the source code. After checking some articles, we find that the problem lies in the editor. Previously I used editplus 2.11 to save the JSP file as UTF-8 encoding and inserted three invisible characters (0xef 0xbb 0xbf, BOM) at the beginning of the file ), it represents the Unicode mark (BOM ). Therefore, the solution is to remove the check box before BOM when saving the code. Emeditor and editplus 2.21 can be used for saving.

& #65279; indicates "Zero Width no-break space". For more information, see
Http://www.fileformat.info/info/unicode/char/feff/index.htm

Test code for problem discovery:
Test. jsp
---------------------
<% @ Page pageencoding = "UTF-8" %>
<% @ Page contenttype = "text/html; charset = UTF-8" %>
<% @ Include file = "1.jsp" %>
<Table>
<Tr> <TD> testing </TD> </tr>
</Table>
<% @ Include file = "2.jsp" %>

1. jsp
---------------------
<% @ Page pageencoding = "UTF-8" %>
<% @ Page contenttype = "text/html; charset = UTF-8" %>
<Div> hehe </div>

2. jsp
---------------------
<% @ Page pageencoding = "UTF-8" %>
<% @ Page contenttype = "text/html; charset = UTF-8" %>
<Div> Haha </div>

The generated Page code is as follows:
---------------------

& #65279;

<Div> hehe </div>
<Table>
<Tr> <TD> testing </TD> </tr>
</Table>
& #65279;

<Div> Haha </div>
---------------------

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.