View Full Version : HTTP POST returns a pdf

21 Jan 2010, 10:49 AM
I have code which currently does a HTTP GET request to bring back a dynamically generated pdf from the server and display in a dialog. Now i have to pass more data back to the server for each pdf so i need to switch over to a HTTP POST.

Does anyone have any examples of doing this? Basically have a dialog pop up with the result from a HTTP POST? Or any pointers?

22 Jan 2010, 10:42 AM
Switching from a GET to POST shouldn't change much. I'm not sure that I understand what your question is?

22 Jan 2010, 2:13 PM
thanks for the response. let me try to explain more...

currently i pop a dialog, set its url to http://someurlWhichGeneratesAPdf?param1=eerfre&param2=ergerga

But now, i need to send a lot of variables to the pdf generator so i need to switch over to a hTTP POST as the URL is getting too big to pass everything. Does this make sense?

24 Jan 2010, 12:03 PM
You can take a look for FormPanel and its submit() method.

25 Jan 2010, 12:33 AM
You can create a serializable java bean that contains all the parameters you need, send it to the server over rpc and store it in the session with its own id which you can then use as the only POST/GET parameter in the request when you need to print/process your parameters on the server.

25 Jan 2010, 11:02 AM
Ohhh... I see what you're trying to do. Since you mentioned setting the "url" on a "dialog" you are using an Iframe. To my knowledge, you can't POST from an Iframe. Therefore, I don't think it is possible.

5 Feb 2010, 12:28 PM
You can take a look for FormPanel and its submit() method.

Thanks. I now have a FormPanel doing a POST to my report servlet and i see the request with parameters coming over. However, the pdf my servlet generates never shows up in the dialog. How do i get the pdf which gets dynamically generated to show where the form was like a regular HTML page does?

7 Feb 2010, 6:47 PM
anyone have any ideas?

7 Feb 2010, 9:21 PM
I don't think that you can post from an IFrame. You have two options:
1) Convert from POST to GET.
2) Have your post request return a URL. That url will point to a public copy of the generated PDF on your server. Set the returned URL to the IFrame. Make sure your server sets the "content-disposition" to "inline" for PDFs.

As far as I see it, those are your options.