File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes How to display a dynamically generated PDF in a new browser using Struts? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to display a dynamically generated PDF in a new browser using Struts?" Watch "How to display a dynamically generated PDF in a new browser using Struts?" New topic
Author

How to display a dynamically generated PDF in a new browser using Struts?

paromitabanerjee mukerjibanerjee
Greenhorn

Joined: Dec 20, 2004
Posts: 23
Scenario: The user selects a Reference no and then clicks button in a jsp. After that, a new window should open up and a dynamically generated PDF should be displayed there.

Problem: -- When I run this as a java application, the PDF file is generated fine. But I am new on Struts. and am not sure of the flow for calling and displaying this servlet.

What I have tried to do: -- In the jsp after the user clicks on the button, I pass the following URL while opening another window.
eg. var mononeyURL = "http://localhost:9080/pcnavms/monroney.do";
openResourceWindow((mononeyURL) , 600, 800, true, true, true, false);

This opens up the new window fine. And in the monroney jsp, I am trying to intantiate the class
eg. monroney.jsp
<%@ page language="java" contentType="application/pdf fullscreen=yes"%>
<% controller.checkPDF.CreatePOVMonroney al = new controller.checkPDF.CreatePOVMonroney();
al.processRequest(request, response);
%>

and in the struts.config file I have declared the following :
<global-forwards>
<forward name="monroney" path="/WEB-INF/jsp/dlrTnRcv/monroney.jsp" />
</global-forwards>

<action-mappings>
<action path="/monroney"
type="controller.dlrTnRcv.MonroneyAction"
name="commonForm"
scope="request"
input="/WEB-INF/jsp/dlrTnRcv/monroney.jsp"
validate="false">
</action>
</action-mappings>

But this doesn't work. Can anyone please help me with this.

thanks,
Paromita
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
In order to help you, we need you to be more specific than "doesn't work". Tell us what's happening that shouldn't or what isn't happening that should, including error messages, stack traces, etc.
[ August 11, 2006: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
paromitabanerjee mukerjibanerjee
Greenhorn

Joined: Dec 20, 2004
Posts: 23
What happens is, it opens up a new window. The File Download Box is displayed.(Save monroney.do) If I click on Save it save a file named monroney.do which has got nothing in it. If I click cancel, then nothing happens. And the new window, anyway disappears.

thanks,
Paromita
paromitabanerjee mukerjibanerjee
Greenhorn

Joined: Dec 20, 2004
Posts: 23
What I am trying here, is generating a PDF file(whose data is dynamically populated) which should be displayed in the new window that has opened (not save it to hard disk).

I can't understand why monroney.do is created as a file and asks for saving it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to display a dynamically generated PDF in a new browser using Struts?
 
Similar Threads
Struts Without Form Bean
Newbie to struts....help with ActionForward error
struts form being cleared in IE 6
problem dispaly error message in struts
Global forward error