These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Handling FDF request objects in java servlet - getting nullPointerException

adoacr
Registered: May 4 2011
Posts: 41

Hi,
 
Im submitting an acrobat form to a servlet using FDF. I created the form using openoffice by setting the URL (without any trailing #FDF, openoffice wouldnt let me) in the form property and the setting the 'submit as' to FDF when exporting to pdf.
 
However the servletrequest object doesnt seem to contain the form fields when I try to query it using the request.getParameter(fieldName) syntax. Is there something I should be doing differently?
 
Here is the brief snippet of my serlvet:
 
public void doPost(HttpServletRequest oReq, HttpServletResponse oRes) throws ServletException, IOException {
System.out.println("***WebserviceTestServlet doPost called****");

OutputStream os = oRes.getOutputStream();
InputStream is = oReq.getInputStream();

String field1= oReq.getParameter("sField1");
String field2= oReq.getParameter("sField2");
 
Both of these fields evaluate to null and my servlet throws a nullPointerException soon afterwards. any pointers? :-)
 
Thanks

My Product Information:
Acrobat Standard 9.2, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1875
Your servlet would have to know how to parse FDF. As it is, it's expecting the form to be submitted as "HTML", which you can set up the submit action to do.
adoacr
Registered: May 4 2011
Posts: 41
any samples/pointers on how to do this? Im thinking the servlet would need to look smewhat similar to http://itextpdf.com/examples/iia.php?id=171 but not sure exactly how to get the parameters for the specific fields from the FDF request inputstream.... Would it be something like this:

protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
// Create a reader that interprets the request's input stream
FdfReader fdf = new FdfReader(request.getInputStream());
HashMap fields = fdf.getFields();
....

How would I proceed from here?