Example: Output multipart/related
In the example below, we are sending back a "multipart/related" format back to the calling client. We are sending a html with 2 images. @Path("/related") public class MyService { @GET @Produces("multipart/related") public MultipartRelatedOutput get() { MultipartRelatedOutput output = new MultipartRelatedOutput(); output.setStartInfo("text/html"); Map mediaTypeParameters = new LinkedHashMap(); mediaTypeParameters.put("charset", "UTF-8"); mediaTypeParameters.put("type", "text/html"); output .addPart( " \n" + "This is me: \n" + " This is you: \n" + "", new MediaType("text", "html", mediaTypeParameters), "", "8bit"); output.addPart("// binary octets for me png", new MediaType("image", "png"), "", "binary"); output.addPart("// binary octets for you png", new MediaType( "image", "png"), "", "binary"); client.putRelated(output); return output; } }