---
title: Error Prone
summary: Rules to detect constructs that are either broken, extremely confusing or prone to runtime errors.
permalink: pmd_rules_jsp_errorprone.html
folder: pmd/rules/jsp
sidebaractiveurl: /pmd_rules_jsp.html
editmepath: ../pmd-jsp/src/main/resources/category/jsp/errorprone.xml
keywords: Error Prone, JspEncoding
---
## JspEncoding

**Since:** PMD 4.0

**Priority:** Medium (3)

A missing 'meta' tag or page directive will trigger this rule, as well as a non-UTF-8 charset.

```
//CompilationUnit/Content[
not(Element[@Name="meta"][
   Attribute[@Name="content"]/AttributeValue[contains(lower-case(@Image),"charset=utf-8")]
]) 
and 
    not(JspDirective[@Name='page']/JspDirectiveAttribute[@Name='contentType'][contains(lower-case(@Value),"charset=utf-8")])
]
```

**Example(s):**

``` jsp
Most browsers should be able to interpret the following headers:

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

<meta http-equiv="Content-Type"  content="text/html; charset=UTF-8" />
```

**Use this rule by referencing it:**
``` xml
<rule ref="category/jsp/errorprone.xml/JspEncoding" />
```

