Highlighted

form with attachment

Avatar

Avatar

AmbikaM

Avatar

AmbikaM

AmbikaM

11-03-2009

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

Replies

Highlighted

Avatar

Avatar

Steve_L_Walker

Total Posts

1.4K

Likes

197

Correct Answer

212

Avatar

Steve_L_Walker

Total Posts

1.4K

Likes

197

Correct Answer

212
Steve_L_Walker

12-03-2009

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
Highlighted

Avatar

Avatar

AmbikaM

Avatar

AmbikaM

AmbikaM

12-03-2009

hi,
Highlighted

Avatar

Avatar

AmbikaM

Avatar

AmbikaM

AmbikaM

12-03-2009

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.