Years ago I had developed a web application that served a PDF document with fillable fields. The user would fill in the fields, then press a Submit button to send the document back to my application. (They had to have Acrobat Standard to do that in those days, of course, not just Acrobat Reader.) The application used JSP, and defined a servlet to handle the HTTP POST. The servlet references in web.xml were:
<servlet>
<servlet-name>VendorPDFPost</servlet-name>
<servlet-class>extstarweb.VendorPDFPost</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>VendorPDFPost</servlet-name>
<url-pattern>/VendorPDFPost/*</url-pattern>
</servlet-mapping>
and the class was implemented as follows:
public class VendorPDFPost extends javax.servlet.http.HttpServlet
{
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
HttpSession lSession = request.getSession();
String lPDFResultFilename = lSession.getAttribute( "com.KRAHE.ExtSTAR.PDFFilename" ).toString() + ".pdf";
File lOutFile = new File( lPDFResultFilename );
FileOutputStream lOutStream = new FileOutputStream( lOutFile );
InputStream lInStream = request.getInputStream();
StreamReaderWriter lRW = new StreamReaderWriter( lInStream, lOutStream );
lRW.copyAll();
lOutStream.close();
lInStream.close();
lSession.setAttribute( "com.KRAHE.ExtSTAR.importFilename", lPDFResultFilename );
response.sendRedirect( response.encodeRedirectURL( "/ExtSTARWeb/faces/VendorPDFProcessed.jsp" ) );
}
}
What I want to know is, How can I do this today in a JSF-centric way?
NOTE: I did not include code that serves the PDF to the user, as I already do that sort of thing in JSF. The key piece of that logic from my old code is response.encodeURL( "/ExtSTARWeb/VendorPDFPost/submit" ), which creates the URL that gets attached to a Submit button in the PDF, so Acrobat/Reader knows where to submit the document.
EDIT:
The short version of my question is: How can I craft a URL/URI that I can attach to a Submit button in a dynamically generated PDF form served by my JSF application that will post the document back to the application when the user presses the button in Acrobat Reader, and then how do I catch that POST in my JSF application?
EDIT 10/6/21:
It turns out that this is really a moot question, as the mechanism I am looking to use requires running Acrobat/Reader as a plug-in within the browser window, which is no longer possible since most browsers dropped support for NPAPI some time ago, as described on the following pages.
Discontinuation of NPAPI browser plugins and its impact
Why do Java, Silverlight, Adobe Acrobat and other plugins no longer work?