I have a servlet running on one web server, which should display a selected PDF file in a frame set.
The PDF file is residing on another server that requires authentication - that is Apache with Basic authentication.
So, in my servlet I'm using the apache HttpClient to send the authentication (username/password).
And that all finishes correctly - as I can see in the log file of the Sun Java Web server, on which the servlet is running.
The problem begins when I want to display the PDF file to the user. If I use the following:
PrintWriter out = res.getWriter();
out.write(get.getResponseBodyAsString());
The PDF is displayed in a new window, not in the original window where the frame set is defined.
If I use the following:
responseBody = get.getResponseBodyAsString();
Header[] responseHeaders = get.getResponseHeaders();
for (int i=0; i><responseHeaders.length; i++){
out.print(responseHeaders);
}
out.println(responseBody);
I get the output in the original window, where the frameset is defined, but the output is as plain text - with special characters - the PDF is not displayed as expected.
Can someone, please, tell me how to display the PDF after the authentication?