permaculture playing cards*
The moose likes Struts and the fly likes struts-jasper report-pdf-jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts-jasper report-pdf-jsp" Watch "struts-jasper report-pdf-jsp" New topic
Author

struts-jasper report-pdf-jsp

mizkhyz garcia
Greenhorn

Joined: May 15, 2011
Posts: 1
Hi everyone,

I am new here and also in using struts. I have this problem I encountered when I integrate jasper report with struts.
I am able to produce the pdf of my report but then i want it to be place it inside a frame in my jsp page.

What will I do? any suggestion?


Codes:

public class GenerateReportAction extends Action {

private static Logger log = Logger.getLogger(GenerateReportAction.class);

@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {


ActionForward forward = new ActionForward();
GenerateReportForm jform = (GenerateReportForm) form;


InputStream is = JSFHelper.getCurrentLoader("").getResourceAsStream("/jasper/sampleLetter.jasper");
log.info("value of InputStream " + is);


try{

JasperReport jasperReport = (JasperReport)JRLoader.loadObject(is);
JasperPrint jasperPrint = (JasperPrint)JasperFillManager.fillReport(jasperReport,new HashMap(),newJREmptyDataSource());

response.setContentType("application/pdf");
request.setAttribute("resourceReports", jasperPrint);

}
catch(Exception e){

e.printStackTrace();

}


forward = mapping.findForward("success");
return forward;
}

}

-------------------------------------------------------------------


public class GenerateReportForm extends ActionForm {

//nothing here

}



----------------------------------------------------------------

in my jsp:

<html:form action="generateReport">

<input type="submit" name="cmdGenerate" id="cmdGenerate" value="Generate" class="buttons" />

<iframe id="pdfFrame" width="100%" height="500px"
src="${requestScope.resourceReports}"
width="100%"
height="500px">
</iframe>

</html:form>




-------------------------------------

struts.config.xml


<form-beans>
<form-bean name="generateReportForm" type="sample.form.GenerateReportForm"></form-bean>
</form-beans>


<action-mappings>
<action path="/generateReport"
type="sample.action.GenerateReportAction"
name="generateReportForm"
scope="request"
input="/genRepLet.jsp">

<forward name="success" path="/jsp/genRepLet.jsp"></forward>
</action>
</action-mappings>



Thank you in advance.
naresh kumar k
Ranch Hand

Joined: May 25, 2011
Posts: 30
Hi mizkhyz garcia,
I started using Jasper Reports in my application but could not find correct process to implement this.
I am using struts with hibernate could please guide me to implement jasper reports in my application.
can you give me the code to use jasper reports and the procedure to follow to implement this.

kindly please help me.
thanks in advance


regards
naresh kumar k
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts-jasper report-pdf-jsp
 
Similar Threads
DynaActionForm - Exception creating bean
ServletException in:/pages/logon.jsp] Cannot retrieve definition for form bean null'
Struts 2 - JasperReport problem
iReports - HTML format in JSP
Struts and JSP problem :(