File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes generating pdf from jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "generating pdf from jsp" Watch "generating pdf from jsp" New topic

generating pdf from jsp

Swathi Ram

Joined: Sep 18, 2007
Posts: 27
Hey all.....

I'm trying to figure out a way to generate a pdf file using struts 2. Does Struts facilitate this??
I came across some examples that used jasperreports........if anyone has info on this or any other suggestion or any sample code, please help.

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33124

Struts is just a framework. You need to plugin a library to generate the PDF like Jasper or iText (open source PDF generator)

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Swathi Ram

Joined: Sep 18, 2007
Posts: 27
I tried to implement the JasperReport to generate a pdf.

I created the template and action class and put the following action mapping in my struts.xml

<result-type name="jasper" class="org.apache.struts2.views.jasperreports.JasperReportsResult" />

<action name="myJasperTest" class="com.nursefinders.JasperAction">
<result name="success" type="jasper">
<param name="location">/jasper/jasper_output.jasper</param>
<param name="dataSource">myList</param>
<param name="format">PDF</param>

But I don't have jasperreports.JasperReportsResult in my org.apache.struts2.views. How do I get that???
Do I need to have any plugin for that? If so which one?

I agree. Here's the link:
subject: generating pdf from jsp
It's not a secret anymore!