• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Opening a PDF file from JSP Page using Java Script

 
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Ranchers,

I am using Jasper Report to export the report to PDF file. After exporing the file, I want the PDF to be opened automatically. I need to do the script in body onload to make it simple.

I have tried to do something, and failed Please help me to solve the issue. Below are the source code.



Please help me.

Thanks/Regards

Aravind Prasad
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Aravind Prasad wrote:I am using Jasper Report to export the report to PDF file. After exporing the file, I want the PDF to be opened automatically. I need to do the script in body onload to make it simple.



The simple way to do that is just to write the output to the response and write the appropriate headers to specify that the response is a PDF file and not HTML. It's even simpler if you do it in a servlet and don't have all the JSP overhead confusing things. Especially since JSP is for generating HTML and you don't want to generate HTML.

I don't get what your Javascript was supposed to be doing... it seems to be trying to open a file on the client's computer, but that doesn't make any sense at all. But that doesn't matter because Javascript isn't the solution here anyway.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic