This question already has an answer here:

Hello I am creating Geoserver view to view my result and for zoom to result. My Sql Query is like SELECT * FROM geotable WHERE gid IN (%gid%)

View Parameters to Query like 1,2,3

Regular Expression like '^[\w\d\s]+$'

My Zoom function like

  function binddata(data) {
        myObject = JSON.parse(data.d);
        gid = [];

        for (var i = 0; i < myObject.length; i++) {
        //var plcd = plcd1[0];
        ZoomtoParcelsByAcers(gid, SearchResultsLayer);

//Function to escape comma in viewparameters
    String.prototype.replaceAll = function (search, replacement) {
        var target = this;
        return target.replace(new RegExp(search, 'g'), replacement);

    function EscapeCommasSemiColons(input) {
        return input.toString().replaceAll(",", "\\,");

function ZoomtoParcelsByAcers(gid, SearchResultsLayer) {

            url: 'http://localhost:8080/geoserver/plotgeo/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=plotgeo:vwnew&maxFeatures=5000&outputFormat=text/javascript',
            contentType: 'application/json',
            dataType: 'jsonp',
            jsonpCallback: "parseResponse",
            data: {

                viewparams: "gid:" + EscapeCommasSemiColons(gid)

            success: function (response) {



When i pass multiple parameters in geoserver it is working fine. When i am using above code to zoom to result i am gettin Error like

      java.lang.RuntimeException: java.io.IOException
java.io.IOExceptionInvalid value for parameter gid

Can anyone help what is error in it.

marked as duplicate by Ian Turton Nov 2 '16 at 8:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • I am Doing same but i am getting error like "java.lang.runtimeException" – indu Nov 2 '16 at 9:05
  • I solved this issue by ading regular expression in geoserver ^[\d,]+$ – indu Nov 2 '16 at 11:43