Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

open a pdf report in a new window

 
sai kinnera
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
sai kinnera
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Merrill. I am not into AJAX yet. But I will try.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic