tags:

views:

50

answers:

3

How to pass the whole pdf content as response in Restful web services using java platform. I tried with converting the responses to String and byte array. First case, got registered expression error. In Second case, getting unexpected results.

+1  A: 

PDF data should be transferable as a response of a rest-ful request just fine.

Set the correct content type and transfer the binary content of the PDF.

Nothing special about it.

  1. What are you doing right now? Are you using an library?
  2. Describe your "unexepected results".
  3. Describe your "expression error"

Basically, you need to provide a lot more details.

Joachim Sauer
undisputed
Looks like a PDF file to me. I assume you didn't set the content type. Of course it's not HTML or XML. The content type is `application/pdf`.
Joachim Sauer
Thanks.Now I need to display the same data in pdf file. how to do it,
undisputed
**It already is a PDF file!** You only need to tell the client the correct mime type, which I already told you! Please do some reading on the HTTP protocol and how it transmits data and metadata. You need to set the right header.
Joachim Sauer
undisputed
What are you talking about? What kind of client do you use to access that data? How do you display it? How do you store it?
Joachim Sauer
I m calling the web service using the applet. Getting the pdf data in client applet. Using IText to create the pdf file in the local.
undisputed
A: 

Your responses from the Java platform are most definitely going to be byte arrays in order to provide the PDF. From the server side you need to make sure that MIME types for PDF are registered and that it's providing and accepting the correct headers for PDF.

If you're serving PDF, Java needs to figure out where that is and hosted under the url that you defined your RESTful resource.

If it's dynamic, your PDF library (I've used iText in the past) needs to be able to output the PDF binary and serve it via your defined RESTful resource.

Synthesis
A: 

Not sure if this is related to your problem - but I have seen that Adobe Acrobat doesn't handle HTTP Range headers well and if you say you except Ranges it will throw some very weird Range requests and ignore the partial content headers you send back. Just a warning.

Gandalf