Pages Navigation Menu

Coding is much easier than you think

Displaytag export option is not working- Solution

Displaytag export option is not working- Solution

 
In this article we will learn to resolve the issue which occurs while exporting the file using display tag,

 
In order to enable export functionality in display tag, configure display tag in JSP as shown below.
 

<display:table name="studentList" pagesize="5" export ="true" requestURI="/displaytag.jsp">
<display:column property="rollNo" title="Roll No"/>
<display:column property="studentName" title="Student Name"/>
<display:column property="department" title="Department"/>
<display:column property="rank" title="Rank"/>
</display:table>

 
Here export=”true” option enable export functionality in displaytag.
 

Displaytag Export Issue

 

After enabling displaytag export functionality, though it was working in test program, export option on display tag for CSV, Excel, XML and PDF was not working on actual project.
 
** UPDATE: Struts 2 Complete tutorial now available here.
 
My Application throws the following exception and error message, when user clicks on export button :
org.displaytag.exception.BaseNestableJspTagException Exception: [.TableTag] Unable to reset response before returning exported data. You are not using an export filter. . . . configure the export filter.
 

Cause of Displaytag export problem:

 
This issue occurs when you have declared filter in web.xml
 

Solution :

 
To fix displaytag export issue the following steps are needed to be followed:
 
Add ResponseOverrideFilter filter as shown below.
 

<filter>
        <filter-name>ResponseOverrideFilter</filter-name>
        <filter-class>org.displaytag.filter.ResponseOverrideFilter</filter-class>
</filter>
<filter-mapping>
       <filter-name>ResponseOverrideFilter</filter-name>
       <url-pattern>*.*</url-pattern>
</filter-mapping>

 
Make sure that display tag’s ResponseOverrideFilter placed as first filter in web.xml
 
Related Questions:

How to make Struts 2 tag work inside Display tag?
How to get checkbox values from displaytag using struts2
 

About Mohaideen Jamil


Am currently working as a Struts 2 Developer in a reputed IT Organisations. I can help you with teaching Core java and Struts 2. Follow me on Facebook or Google Plus. If you like my tutorials, consider making a donation to this charity, thanks.

  • Harley Seixas

    Can you help me? My displaytag not export to excel when i put my metodo in struts xml:

    consultar

    If remove interceptor, export works fine. Please give some help. Thanks.

  • srinivas

    i got this exception hile using export option in display tag.
    please give me rply…urgent.
    ognl.ParseException: Encountered ” “7274 “” at line 1, column 9.
    Was expecting one of:

    “,” …
    “=” …
    “?” …
    “||” …
    “or” …
    “&&” …
    “and” …
    “|” …
    “bor” …
    “^” …
    “xor” …
    “&” …
    “band” …
    “==” …
    “eq” …
    “!=” …
    “neq” …
    “” …
    “gt” …
    “=” …
    “gte” …
    “in” …
    “not” …
    “<>” …
    “shr” …
    “>>>” …
    “ushr” …
    “+” …
    “-” …
    “*” …
    “/” …
    “%” …
    “instanceof” …
    “.” …
    “(” …
    “[” …

    • http://www.simplecodestuffs.com Mohaideen Jamil

      Your data has some special character.. Display tag leads to above problem if data has special character in them ….. you can decode those data before adding into display tag list..