Search code examples
javaspring-mvcdisplaytag

export to pdf,excel,xml using displayTag with spring not working


I am using display tag in jsp and its not working. I am using spring MVC framework for backend. Perhaps jsp is not able to identify display tag. I have included all required jars for spring and display tag.

my jsp code:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib uri="http://displaytag.sf.net" prefix="display" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>

</head>

<body>

    <div>
        <c:if test="${not empty recordList}">
        <display:table id="txt" pagesize="10" requestURI="" name="recordList">
            <display:column property="trafficType"></display:column>
            <display:column property="publisherId"></display:column>
            <display:column property="publisherName"></display:column>
            <display:column property="publisherGroupDevice"></display:column>
            <display:column property="clicks"></display:column>
            <display:column property="cost"></display:column>
            <display:column property="merchantSales"></display:column>
        </display:table>
        </c:if>
    </div>

</body>

</html>

and my controller include this line

model.addAttribute("recordList", recordList);

I am getting this error on console

    INFO  aytag.export.ExportViewFactory - Initializing ExportViewFactory with type={csv,excel,xml,pdf}
2016-05-19 22:35:55,660 [http-bio-8080-exec-2] INFO  tag.properties.TableProperties - No LocaleResolver configured.
2016-05-19 22:35:55,698 [http-bio-8080-exec-2] INFO  tag.properties.TableProperties - I18nResourceProvider initialized to org.displaytag.localization.I18nJstlAdapter.
2016-05-19 22:35:55,891 [http-bio-8080-exec-2] ERROR                 nextagBase.jsp - forwarding to URL (iDChnl == null): /serv/main/serv/main/internal/v1/generateReport failed.
java.lang.IllegalStateException: Cannot forward after response has been committed
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:348)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:338)
    at nextag.api.Jsp.forward(Jsp.java:4472)

Solution

  • I am sorry that I posted this question; but after a lot of debugging I found that it was my mistake that display tag is not getting proper list data structure from controller to work upon, so I corrected it and code ran perfectly.