Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7168757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:50:42+00:00 2026-05-28T14:50:42+00:00

I am able to generate a report in pdf form using JasperReports and Java.

  • 0

I am able to generate a report in pdf form using JasperReports and Java.

The generated report is not available to be downloaded to the client side.
I am generating pdf file using the code below:

public void getTaskreportPDF(Session openSession,HttpServletRequest request,HttpServletResponse response) {
        try {   
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection) DriverManager.getConnection("jdbc:mysql://localhost/contact","root","root");
Map params = getParameters(openSession);
Date date = new Date();
String reportfileName = "report"+date.getDate()+"-"+date.getMonth()+"-"+date.getYear()+"-"+date.getTime()+".pdf";
JasperDesign jasperDesign = JRXmlLoader.load(this.getClass().getResourceAsStream("/com/gantt/report/ganttreport.jrxml"));
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
JasperPrint jasperprint = JasperFillManager.fillReport(jasperReport, params,con);
JRAbstractExporter exporterPDF = new JRPdfExporter();
exporterPDF.setParameter(JRExporterParameter.JASPER_PRINT, jasperprint);
exporterPDF.setParameter(JRExporterParameter.OUTPUT_STREAM, response.getOutputStream());
response.setHeader("Content-Disposition", "inline;filename="+ reportfileName);
response.setContentType("application/pdf");
exporterPDF.exportReport();  
} catch(Exception exception) {
System.out.println("Error occured " +exception.getMessage());
}
}

My firebug net tab shows that I had got the pdf report file of 4 kb as response. But the problem is that download window not appear, so I cannot save it or view that report.

My firebug shows:
Content-Disposition inline;filename=report21-0-112-1327135412907.pdf
Content-Type application/pdf

What mistake I am making which makes my download window not to appear?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T14:50:43+00:00Added an answer on May 28, 2026 at 2:50 pm

    Use attachment instead of inline for the Content-Disposition header.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I developed a Windows service using C#.NET to generate PDF report. To generate PDF
I am using reportlab to generate a pdf report automatically from dynamic data. As
What I would like is be able to generate a simple report that is
I want to be able to generate PDF output from my (native) C++ Windows
I'm using Active Reports within my VB program to generate a report based on
I generated Fxcop analysis report using ant script. But I am unable to host
I want to generate an excel report on client users on my network/ intranet.
I am trying to generate a pdf using the Reporting services 2005 webservice. I
Consistently, I am able to generate a Java Heap Space OutOfMemory exception with the
I'm trying to create a report by generating a PDF based on HTML. At

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.