aspose file tools*
The moose likes Struts and the fly likes open a pdf report in a new window Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "open a pdf report in a new window" Watch "open a pdf report in a new window" New topic
Author

open a pdf report in a new window

sai kinnera
Ranch Hand

Joined: Aug 12, 2004
Posts: 52
Hi,
I have a struts action class within which I make a database call to get data for a pdf report. The call is made when a button on a jsp is clicked. If there is no data (after database call inside action), it should give a message on the JSP. This is OK. If there is data, a pdf will be generated and written to the response. Now, I want this pdf to be opened in a new window. (If the no data condition is not there I could open it using target="_blank' at the time of calling the url itself.). Any help is appreciated.
Thanks,
Sai
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
The problem here is that you have to determine the target before you submit the form. I'd suggest making an AJAX call from the JSP to determine whether data exists or not. If it doesn't exist, just display the message without submitting the form. If it does exist, specify target="_blank" and submit the form.

If you're unfamiliar with AJAX, just google "AJAX and Struts" and you'll find some information on it. This thread contains a simple example of an AJAX call to a Struts action.


Merrill
Consultant, Sima Solutions
sai kinnera
Ranch Hand

Joined: Aug 12, 2004
Posts: 52
Thank you Merrill. I am not into AJAX yet. But I will try.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: open a pdf report in a new window