Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

share|improve this question
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 Apr 9 '13 at 3:05

1 Answer 1

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.

share|improve this answer
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 Nov 6 '13 at 15:28
@ca0v this works for WFS only. WMS doesn't return jsonp, AFAIK. –  alexgleith Feb 21 '14 at 3:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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