Which two code fragments are valid for adding an attachment in SAAJ? (Choose two.)
A.
AttachmentPart attachment =
request.createAttachementPart();
String stringContent = Update total;
attachment.setContent(stringContent,text/plain);
attachment.setContentID(update_total);
request.addAttachmentPart(attachment);
B.
Attachment attachment =
request.createAttachement();
String stringContent = Update total;
attachment.setContent(stringContent,text/plain);
attachment.setContentID(update_total);
request.addAttachment(attachment);
C.
URL url = new URL(http://eshop.com/products/tb.jpg); DataHandler datahandler = new DataHandler(url);
AttachmentPart attachment =
request.createAttachmentPart(dataHandler);
attachment.setContentID (attached_image);
request.addAttachmentPart(attachment);
D.
URL url = new URL(http://eshop.com/products/tb.jpg); DataHandler datahandler = new DataHandler(url);
Attachment attachment =
request.createAttachment(dataHandler);
attachment.setContentID (attached_image);
request.addAttachment(attachment);
E.
Attachment attachment =
request.newAttachement();
String stringContent = Update total;
attachment.setContent(stringContent,text/plain);
attachment.setContentID(update_total);
request.setAttachment(attachment);
The question representation is incorrect: quotes are missing.
A) create attachment content with text type
C) create attachment with bin type via dataHandler
A And C Correct ….
http://www.xyzws.com/scdjws/studyguide/saaj_print.html
//Attach an attachment ..
AttachmentPart attachment = message.createAttachmentPart();
String stringContent = “Update address for Sunny Skies “;
attachment.setContent(stringContent, “text/plain”);
attachment.setContentId(“update_address”);
message.addAttachmentPart(attachment);