Java Reference
In-Depth Information
if ("text/plain".equals(type)) {
Object content = attachment.getContent();
System.out.println("Attachment data: " + content);
}
}
}
}
You can find the complete code listing for this method in the file SAAJProviderAttachSer-
vlet.java. It accepts a request that has attachment data, prints the incoming attachment data,
and then creates an attachment for the response. The result of printing the incoming attach-
ment data is as follows:
Getting attachment...
Attachment ID=clientVersion. Content Type=text/plain
Attachment data: Client-Version=1.1
Note that because the Servlet API has not yet been fitted with Java SE 5 language features
such as generics and annotations (that will have to wait until Java EE 6), you indicate that
you're suppressing the compiler warnings regarding your Iterator's type parameter. If you
prefer, you can forget the @SuppressWarnings annotation, use Iterator's raw type, and just
cast Object to AttachmentPart when you call it.next .
See Also
Providing a Web Service with SAAJ .
Search WWH ::




Custom Search