---
title: "tiles 2.1.3 bug: 'ignore' doesn't work for insertDefinition tag"
author: "lerluc"
date: "2009-10-03T05:48:09Z"
tags: ["Apache", "JSP", "Struts", "XML"]
slug: "tiles-2-1-3-bug-ignore-doesn-t-work-for-insertdefinition-tag"
draft: false
lastmod: "2009-10-09T21:55:20Z"
id: 481427
url: "https://lerluc.iteye.com/blog/481427"
---

```xml
<tiles:insertDefinition name="def" ignore="true"/>
```

Description: **"**If this attribute is set to true, and the attribute specified by the name does not exist, simply return without writing anything. The default value is false, which will cause a runtime exception to be thrown.**"**

But in fact, when "def" isn't configured **it throws exception regardless of ignore="true"**.

Workaround:
1) download src of tiles-2.1.3
2) tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/InsertDefinitionTag.java
line 65: (patched)

```java
    protected void renderContext() {
    	boolean isValid = container.isValidDefinition(name, pageContext);
        if(isValid || !ignore)
        	container.render(name, pageContext);
    }
```

3) compile a tiles-jsp.jar and replace the original one
or use [this one](http://dl.iteye.com/topics/download/da959ce1-695f-3a94-b1d7-549168543506) (compiled with jdk1.6. mind the version!)

Another bug with "ignore" for insertAttribute tag

```xml
<tiles:insertAttribute name="attr" ignore="true"/>
```

refer to [JIRA](http://issues.apache.org/struts/browse/TILES-441) for the patch