Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Display PDF file from a server that requires authentication

843841Oct 3 2006
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?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 31 2006
Added on Oct 3 2006
0 comments
135 views