S
sridevisd
Hi,
I am developing an application using WSAD.
I have to open a pdf file from a servlet.
My code goes this way:
public void doPost(HttpServletRequest req, HttpServletResponse
response)
throws ServletException, IOException {
response.setContentType("application/pdf");
response.setHeader("Content-disposition",
"attachment; filename=\"" +"example.pdf" +"\"");
try
{
/*PrintWriter out = response.getWriter();
out.println("Welcome to Acrobat Reader");
out.flush();
out.close();*/
}catch (IOException ioe)
{ System.out.println(ioe);
}catch(Exception e){
System.out.println(e);
}
}
The Acrobat Reader is up but gives the message:
"There was an error opening this document. This file cannot be found"
Where should I place the 'example.pdf' file so it can read it.
2. How can I open the Acrobat Reader inside the browser, instead of an
attachment.
if I uncomment the out.println, or use ServletOutputStream it is
writing the output in the browser and not in a pdf file.
Pls help.
Thanks in advance
Sridevi
I am developing an application using WSAD.
I have to open a pdf file from a servlet.
My code goes this way:
public void doPost(HttpServletRequest req, HttpServletResponse
response)
throws ServletException, IOException {
response.setContentType("application/pdf");
response.setHeader("Content-disposition",
"attachment; filename=\"" +"example.pdf" +"\"");
try
{
/*PrintWriter out = response.getWriter();
out.println("Welcome to Acrobat Reader");
out.flush();
out.close();*/
}catch (IOException ioe)
{ System.out.println(ioe);
}catch(Exception e){
System.out.println(e);
}
}
The Acrobat Reader is up but gives the message:
"There was an error opening this document. This file cannot be found"
Where should I place the 'example.pdf' file so it can read it.
2. How can I open the Acrobat Reader inside the browser, instead of an
attachment.
if I uncomment the out.println, or use ServletOutputStream it is
writing the output in the browser and not in a pdf file.
Pls help.
Thanks in advance
Sridevi