Content type - Restlet

Posted by DutrowLLC on Stack Overflow See other posts from Stack Overflow or by DutrowLLC
Published on 2010-06-12T00:28:09Z Indexed on 2010/06/12 1:32 UTC
Read the original article Hit count: 346

Filed under:
|

How do you set the content type in Restlet (version 2.0 for google app engine)? In this case, I'd like to set the content type to ""text/xml".

I have:

public class SubResource  extends ServerResource {

 @Get
 public Representation get(Representation representation){

    setStatus(Status.SUCCESS_OK);
    StringRepresentation sr = new StringRepresentation(getSomeXml());

    return sr;
 }
}

I'm unsure even if it is a value that is set in the Representation, or if it is set from the ServerResource class the same way that the return code is.

ANSWER:

    StringRepresentation sr = new StringRepresentation(getSomeXml());
    sr.setMediaType(MediaType.TEXT_XML);

© Stack Overflow or respective owner

Related posts about content-type

Related posts about restlet