Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

form with attachment

AmbikaM
Level 4
Level 4
hi all,

im rendering a form through a process(invoking the process through a servlet)... the form will allow the user to attach files. on click of submit button, it calls a servlet. the servlet should check if the form contanins any attachments...if yes it should save the attachments in DB, but when ever i check for attachments in the servlet(console) it says "empty".



and whn i try saving the form in a the local drive and open it, it says not of proper format.now whr is the issue in the form or the way i check for attachments
3 Replies
Steve_L_Walker
Level 10
Level 10
Ambika,



Yesterday I put together a servlet to accomplish a similar task. The following code snippet gets the submitted PDF from the HTTP request input stream, calls Forms ES to render the PDF, gets the attachments from the rendered PDF, and iterates over the attachments. I added comments in the while loop, below, to indicate possible actions.



...

Document formIn = new Document(req.getInputStream());



RenderOptionsSpec renderOptionsSpec = new RenderOptionsSpec();

renderOptionsSpec.setLocale("en_US");



FormsResult formOut = formsServiceClient.processFormSubmission(formIn,

"CONTENT_TYPE=application/pdf",

"",

renderOptionsSpec);



List fileAttachments = formOut.getAttachments();

Iterator iter = fileAttachments.iterator();

int i = 0 ;



while (iter.hasNext()) {

Document fileAttachment = (Document)iter.next();

// do DB processing or validate the attachments using...

// File myFile = new File("C:\\attachment" + i + ".pdf");

// fileAttachment.copyToFile(myFile);

i++ ;

}

...



Steve
AmbikaM
Level 4
Level 4
hi walker,



the same thing i did, still nothing seems to work.It always prints in the console as "attachments empty." please help me out in resolving this issue.