Saving a servlet response when it is a pdf generated with oracle's report server

1.3k views Asked by At

My application is deployed on Oracle's OAS (ADF environment). My application is a simple form with a submit button. When it's clicked I send a request the Oracle's report server (to the rwservlet). My request look something like this:

http://<server>:<port>/reports/rwservlet?report=<report_name>&userid=<userid>/<password>@<connect_string>&desformat=pdf&destype=cache

This generates a PDF report and returns to the user's browser. I'd like to get that PDF report and save it to my local server as well (so I have 2 servers: the OAS server and the Reports Server - and I called the report on the Reports server and return to the client. I just want to intercept the process and save the report on the OAS server).

To send the request, I used a servlet on my OAS server. I want to somehow get the PDF from my response object (that's my plan). I don't know if this is possible.

1

There are 1 answers

3
BalusC On BEST ANSWER

You can't intercept/copy client's request. You've to request it programmatically with another HTTP request.

InputStream input = new URL("http://<server>:<port>/reports/rwservlet?report=<report_name>&userid=<userid>/<password>@<connect_string>&desformat=pdf&destype=cache").openStream();
// ...

Just write it to an arbitrary OutputStream the usual Java IO way. For example, a FileOutputStream.