code: @Override
      public void writeTo(final Viewable viewable,
                          final Class<?> type,
                          final Type genericType,
                          final Annotation[] annotations,
                          final MediaType mediaType,
                          final MultivaluedMap<String, Object> httpHeaders,
                          final OutputStream entityStream) throws IOException, WebApplicationException {
          try {
              final ResolvedViewable resolvedViewable = resolve(viewable);
              if (resolvedViewable == null) {
                  final String message = LocalizationMessages
                          .TEMPLATE_NAME_COULD_NOT_BE_RESOLVED(viewable.getTemplateName());
                  throw new WebApplicationException(new ProcessingException(message), Response.Status.NOT_FOUND);
              }
  
              MediaType mType = resolvedViewable.getMediaType();
              if (mType == null || mType.isWildcardType()) {
                  mType = mediaType;
              }
  
              httpHeaders.putSingle(HttpHeaders.CONTENT_TYPE, mType);
              resolvedViewable.writeTo(entityStream, httpHeaders);
          } catch (ViewableContextException vce) {
              throw new NotFoundException(vce);
          }
      }
docs: {@inheritDoc}