Skip to main content
Skip table of contents

How to send a success response back to Acrobat Reader from a java servlet?

How do I send a response back to the Acrobat Reader as a java servlet response?

I am generating an editable PDF form at the server side and sending it to the browser. At the client side, I am saving the PDF and adding the fields and submitting it via Acrobat Reader. Now once the servlet has read the form fields, I wan to send a success response back to the Acrobat Reader letting the user know that the form has been successfully submitted.

How do I send a response back to the Acrobat Reader as a java servlet response?

Posted on StackOverflow on Jul 21, 2014 by user3207455

What do you want the end user to see?

Some options:

  1. Usually, I send back simple HTML saying "Thank you for submitting your form." When the form is archived, I add a link to the filled out form so that people can check what they've filled in.
  2. You could return the filled out form in PDF, but add some document-level JavaScript that opens an alert that says "This form was submitted on 2014-07-21". If you don't like the JavaScript (it can be annoying to see such an alert), why not stamp that message on the filled out form.
  3. When I don't want anything to happen, I send a response code "204 No Content" to the browser. In that case, nothing happens. That's not what you want, but maybe you can return "200 OK" or "202 Accepted". The end user won't see much, but the browser will know what happened. More info can be found on the W3C site.

In many cases, it's common to send a mail with either the link mentioned in (1) or the actual filled-out PDF.

Note that option (1) is only valid when you submit the form from a browser, using Adobe Reader / Acrobat as a plug-in. When using Adobe Reader / Acrobat as a standalone application, you'll have to use option (2) or (3), because Adobe Reader / Acrobat can't interpret HTML and will throw an exception saying that it has received content that can't be read.

Thanks for your response. But if I have to send a javascript alert as a response to the stand-alone acrobat reader, what would be the content-type for the response? Would it be application/pdf or application/vnd.fdf?

AFAIK both are possible. Note that you can also use an annotation instead of JavaScript.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.