This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
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
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.