[opencms-dev] Response-ContentType XML with OpenCms (JSP) ?

Michael Moossen m.moossen at alkacon.com
Wed Sep 2 11:37:51 CEST 2009


Hi Hendrik!

you have to use something like this:

// set the mime type to application/json
CmsFlexController controller = 
CmsFlexController.getController(getRequest());
controller.getTopResponse().setContentType("application/json");

HTH
-------------------
Michael Moossen

Alkacon Software GmbH  - The OpenCms Experts
http://www.alkacon.com - http://www.opencms.org

Hendrik Konitzer schrieb:
> Hi,
> 
> were trying to generate a XML-Output via JSP to process es further with 
> jQuery.
> 
> But the problem is, the returned Contenttype for the response is always 
> text/html and therefore, jQuery refuses the processing.
> 
> We set the Content-Type in the JSP with various methods, directly with 
> <% response.setContentType("text/xml;charset=UTF-8");%> or as page 
> directive like <%@ page contentType="text/xml; charset=UTF-8"%>.
> 
> But the response is always text/html, it seems that OpenCms forced the 
> ContentType to this.
> 
> Therefore, when it comes to (jQuery Javascript): 
> $.post("joedoe.jsp",{},processXML(data),"xml"); - it fails.
> 
> How to set the ContentType of the response of OpenCms-JSPs to other than 
> "text/html" ?
> 
> Thanks for attention,



More information about the opencms-dev mailing list