Hello,
Using: (v8.2p_2012-07-30/PowerEdition Deployment 2012-07-30)
I have a POST servlet that generates some special PDF file.
Rather than storing it on the server, and returning a download link, I would like to let the browser download it immediately (ie. return a http response of content-type application/pdf).
I use the Content-type: application/pdf return header, and verified using firebug that the PDF is in the response.
Yet it doesn't trigger the download.
I trigger the servlet from the client as follows:
In the servlet, I use the normal httpresponse to return it (ie. not using rpc.send(rpcReq, rpcResp), should i?)
Server code that outputs the data to the client
If i specify an RPCCallback, I can also see in the rawData variable that a PDF is returned.
Should I trigger this thing differently from the client for my purpose?
Any advice is welcome!
Using: (v8.2p_2012-07-30/PowerEdition Deployment 2012-07-30)
I have a POST servlet that generates some special PDF file.
Rather than storing it on the server, and returning a download link, I would like to let the browser download it immediately (ie. return a http response of content-type application/pdf).
I use the Content-type: application/pdf return header, and verified using firebug that the PDF is in the response.
Yet it doesn't trigger the download.
I trigger the servlet from the client as follows:
Code:
private void generatePdfOnServer(List<String> pages){ RPCRequest request = new RPCRequest(); request.setActionURL(GWT.getModuleBaseURL() + "sc/GeneratePdf"); request.setHttpMethod("POST"); request.setShowPrompt(false); request.setWillHandleError(true); Map<String, Object> params = new HashMap<String, Object>(); params.put("template","kitchenlist_template.html"); params.put("pages", pages); params.put("placeholder", "__CONTENT__"); request.setData(params); RPCManager.sendRequest(request); }
Server code that outputs the data to the client
Code:
.... //response is of type HttpServletResponse passed in in doPost(...) response.setContentType("application/pdf"); OutputStream os = response.getOutputStream(); ITextRenderer renderer = new ITextRenderer(); renderer.setDocumentFromString(html); renderer.layout(); renderer.createPDF(os); //writes to the output stream renderer.finishPDF();
Should I trigger this thing differently from the client for my purpose?
Any advice is welcome!
Comment