Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
paromitabanerjee mukerjibanerjee
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
paromitabanerjee mukerjibanerjee
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic