Creato da
Share My Page
My Social Accounts
Account FaceBook Account LinkedIn Account Twitter Account Google Plus Account Git Hub

Display Tag includes a few ready made export views which allow you to export data in CSV, excel, and XML format.

First of all, install Display Tags Library:

After that:
Set in the web.xml the filter:

    <!-- Display tag export filter -->
        <filter class> org.displaytag.filter.ResponseOverrideFilter     </filter-class>

Include the taglib in the JSP where you want enable exports:

    <%@ taglib uri="" prefix="display" %>

Set the buffer page in the JSP where you want enable exports:   

    <%@ page buffer = "16kb" %>

Now you have to develop and create a Servlet or an Action:

In your servletExport you will have:

    request.setAttribute( "listExample",myList);
    RequestDispatcher dispatcher = request.getRequestDispatcher("/redirect/export.jsp");

In your JSP (export.jsp) you will have this code:

<display:table name="listExample"
    requestURI="/wellness/servlets/export" id="misure_export"
    pagesize="5" cellspacing="10" cellpadding="0" export="true" >
    <display:column title="FieldFirst" >
        <c:out value="${misure_export[0] }"/>

    <display:column title="FieldSecond" >
        <c:out value="${misure_export[1] }"/>

    <display:setProperty name="export.excel.filename" value="file.xls"/>
    <display:setProperty name="export.xml.filename" value="file.xml"/>
    <display:setProperty name="export.csv.filename" value="file.csv"/>

</display:table >

If you want more information, you can read the Orginal Documentation:


Average (1 Vote)
The average rating is 5.0 stars out of 5.