Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Problem Opening the PDF document using the servlet

  Asked By: Seth    Date: Mar 03    Category: Java    Views: 1233
  

I have a problem in opening the PDF document which is saved in the database. I
am trying to open the PDF data from the database by using mime-type/content
type as application/pdf in servlet.

Please suggest me for solution.

Thanks for your attention....

Share: 

 

5 Answers Found

 
Answer #1    Answered By: Angelica Ramos     Answered On: Mar 03

have you set the content type in your
application's web.xml file????

 
Answer #2    Answered By: Lonnie Rogers     Answered On: Mar 03

No, just in the servlet/jsp...................

 
Answer #3    Answered By: Hubba Akhtar     Answered On: Mar 03

I read too fast and whether it's necesary to put the
contenttype in the web.xml. I think it's not necessary, you just have to set
this value in the servlet.

 
Answer #4    Answered By: Sumitra 2004     Answered On: Mar 03

As specified below I am trying to open  the pdf  Document by using servile, in my
code i am setting the Mime type - application/pdf.

Here i am sending my code, Please take a look and suggest  me for the best
possibility.

public void service(javax.servlet.ServletRequest req,
javax.servlet.ServletResponse res)
throws javax.servlet.ServletException, java.io.IOException
{
HttpServletResponse hResponse = (HttpServletResponse) res; // Creating the
responce object.
String sMimetype = "application/pdf";
hResponse.setContentType(sMimetype);
hResponse.setStatus(hResponse.SC_OK);
OutputStream out = hResponse.getOutputStream();
byte[] bOutput = (byte[])agaDataDoc.getProperty("doccon"); // Reading the
document content from the database  and costing into byte array.
out.write(bOutput);
}

 
Answer #5    Answered By: Betty White     Answered On: Mar 03

you should try this code in doGet or doPost methods.

 
Didn't find what you were looking for? Find more on Problem Opening the PDF document using the servlet Or get search suggestion and latest updates.




Tagged: