title: Multiple distinct Content-Disposition headers received from server in Jasperreports
body: <p>I'm trying to set content-disposition header in response of servlet, but i get this error in browser. What should i do?</p>
  <blockquote>
  <p><strong>Duplicate headers received from server</strong></p>
  <p>The response from the server
  contained duplicate headers. This problem is generally the result of a
  misconfigured website or proxy. Only the website or proxy
  administrator can fix this issue.</p>
  <p>Error 349 (net::ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION): Multiple
  distinct Content-Disposition headers received. This is disallowed to
  protect against HTTP response splitting attacks.</p>
  </blockquote>
  <p>Here my servlet controller:</p>
  <pre><code>@RequestMapping(&quot;/**/paymentOrderReport.pdf&quot;)
  public class PaymentOrderReportViewController extends org.springframework.web.servlet.mvc.AbstractController {
      
      private PaymentDao paymentDao;
      private JasperPdfView pdfView;
  
      @Override
      protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
  
          response.setContentType(&quot;application/pdf&quot;);
          response.setHeader(&quot;Content-disposition&quot;, &quot;attachment; filename=&quot; + &quot;report.pdf&quot;);
  
          PaymentOrderEntity paymentOrderEntity = null;
          String traceCode = request.getParameter(ParamConstants.TRACE_CODE);
  
          if (traceCode != null) {
              PaymentSheetRequestEntity payRequestEntity = paymentDao.loadByUniqueProperty(PaymentSheetRequestEntity.PROP_TRACE_CODE,
                      traceCode);
              if (payRequestEntity != null) {
                  paymentOrderEntity = payRequestEntity.getPaymentOrder();
              }
          }
  
          if (paymentOrderEntity != null) {
              List&lt;PaymentOrderEntity&gt; result = new ArrayList&lt;PaymentOrderEntity&gt;();
              result.add(paymentOrderEntity);
              JRDataSource jrDataSource = new JRBeanCollectionDataSource(result);
  
              Map&lt;String, Object&gt; model = new HashMap&lt;String, Object&gt;();
              model.put(&quot;reportData&quot;, jrDataSource);
  
              return new ModelAndView(pdfView, model);
          }
          return null;
      }
      
      public void setPaymentDao(PaymentDao paymentDao) {
          this.paymentDao = paymentDao;
      }
  
      public void setPdfView(JasperPdfView pdfView) {
          this.pdfView = pdfView;
      }
  }
  </code></pre>
  <p>And JasperPdfView Class:</p>
  <pre><code>public class JasperPdfView extends AbstractJasperReportsView {
      
      @Override
      protected void renderReport(JasperPrint populatedReport, Map&lt;String, Object&gt; model, HttpServletResponse response) throws Exception {
          JRPdfExporter jrPdfExporter = new JRPdfExporter();
          if (getConvertedExporterParameters() != null) {
              jrPdfExporter.setParameters(getConvertedExporterParameters());
          }
          jrPdfExporter.setParameter(JRExporterParameter.JASPER_PRINT, populatedReport);
          jrPdfExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, response.getOutputStream());
          jrPdfExporter.exportReport();
      }
      
  }
  </code></pre>