This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
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

Win a copy of Elasticsearch in Action this week in the Big Data forum!
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: 31588

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]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, 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?

subject: generating pdf from jsp