I'd like to enable jsonp on GeoServer 2.3.0. The docs say to set ENABLE_JSONP to true.

A response from the GeoServer users list says to edit web.xml, (set System variable ENABLE_JSONP=true and outFormat=text/javascript )but I have no idea which xml tags to use and where to put it.

Here are installed versions: GeoServer 2.3.0 (Web Archive)has been installed on a remote host with tomcat 7.0.39

  • Can you update the question to provide a link to the "docs"? You might also like to explain the specific source of your GeoServer install (e.g. from source, distro packages, some windows installer, etc).
    – BradHards
    Commented Apr 9, 2013 at 3:05
  • It's not made obvious in the resources out there that this needs to be done. Here is the doco atm: docs.geoserver.org/latest/en/user/services/wfs/… Commented Jun 8, 2015 at 13:26

2 Answers 2


I got some help on the GeoServer users list.

Add to this file: /tomcat/webapps/geoserver/WEB-INF/web.xml


and restart the service. Then, in your json request use format=text/javascript

Here's the code I used to request the WFS features from GeoServer. I'm using the Leaflet API along with jquery.

var rootUrl = 'http://tomcat.capecodgis.com/geoserver/capecodgis/ows';

var defaultParameters = {
    service: 'WFS',
    version: '1.0.0',
    request: 'GetFeature',
    typeName: 'capecodgis:monitor_station',
    maxFeatures: 200,
    outputFormat: 'text/javascript',
    format_options: 'callback: getJson'


var parameters = L.Util.extend(defaultParameters);

    url: rootUrl + L.Util.getParamString(parameters),
    dataType: 'jsonp',
    jsonpCallback: 'getJson',
    success: handleJson

function handleJson(data) {
    L.geoJson(data, {
        onEachFeature: onEachFeature,
        pointToLayer: function (feature, latlng) {
            return L.circleMarker(latlng, geojsonMarkerOptions);
            //return L.marker(latlng);

Hopes this gets you started and feel free to ask for more info.

  • This if for WMS only? If not, can you provide an example endpoint? I'm trying to use JSONP for a WFS service but can't get it working (Failed to find response for output format jsonp):…
    – ca0v
    Commented Nov 6, 2013 at 15:28
  • 1
    @ca0v this works for WFS only. WMS doesn't return jsonp, AFAIK.
    – Alex Leith
    Commented Feb 21, 2014 at 3:47
  • Apparently, according to osgeo-org.atlassian.net/browse/…, setting the context parameter did not work in Geoserver 2.3.0. I've wasted half a day chasing that down. I really need to get an up-to-date Geoserver running...
    – Auspex
    Commented Jan 26, 2017 at 14:22

In order to improve readability you can also put the params directly into the AJAX call.

With the JSONP call you won't need the format_options or the success parameter. The callback function will be set with jsonpCallback parameter on the AJAX call and the format_options will be set with jsonp:'format_options'.

        type: 'GET',
        data: {
            service: 'WFS',
            version: '1.0.0',
            request: 'GetFeature',
            typeName: 'capecodgis:monitor_station',
            maxFeatures: 200,
            outputFormat: 'text/javascript',
            request: 'GetFeature',
            srsname: 'EPSG:3857',
            bbox: extent.join(',') + ',EPSG:3857'
        dataType: 'jsonp',
  • Nice example but I didn't pick up on it immediately. The docs state that you can change the callback name via the "format_options" query string using the "callback" options. This example changes the default callback to "tests": [path_to_wfs_service]?format_options=callback:test
    – ca0v
    Commented May 19, 2018 at 3:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.