1

I have a shapefile loaded in GeoServer 2.8 and accessed by OpenLayers 2.13. This layer is in UTF-8 encoding and has some english and non-english records.
When i use english fields in cql-filter - as follows, but no differnce between WMS and WFS request- GeoServer filters data very well and returns the result.

layer1 = new ol.layer.Image({
            title: 'Ostan',
            source: new ol.source.ImageWMS({
                url: 'http://localhost:8080/geoserver/wms',
                params: {
                    LAYERS: 'ws:layer1',
                    VERSION: '1.1.1',
                    CQL_FILTER: "NAME_ENG = 'sommy'"
                }
            })
        });

But if i try to use a field which contains non-english data in cql-filter, GeoServer returns no data. My webpage has following meta, as well:

<meta content="text/html; charset=utf-8" http-equiv="content-type" />

When i check geoserver log, i see some messy characters instead of my non-english string in cql-filter.

  • can you check what is actually set (in the network tab of your debugger) – Ian Turton Aug 3 '16 at 16:11
  • Using Firebug, in Parameteres section, everything is correct. I see "CQL-Filter: Name = 'سامی' " which is right for arabic language. But in Geoserver log, i see some dummy characters instead of abovementioned arabic characters. – ALalavi Aug 3 '16 at 20:29
  • I used another shapefile with Win-1256 encoding and no help. Can anyone confirm that using characters other than ASCII is possible in CQL-Filter? – ALalavi Aug 4 '16 at 7:55
  • what happens if you URLEncode the request? – Ian Turton Aug 4 '16 at 8:20
  • You mean using encodeURIComponent() for the query string?! If so, I've tried that. GeoServer gives a long trace for the error and says that "Could not parse CQL filter list. Lexical error at line 1, column 5. Encountered: "%" " . If i don't use that, It sounds from log file that GeoServer runs the query but it misunderstoods the query stying. In this case, log file shows: "CQLFilter = [[ NAME = ?????±?§?? ]]" – ALalavi Aug 4 '16 at 8:35
0

So Answer is (All credit goes to to Ben Caradoc-Davies and GeoServer mailing list. Thanks them):
Adding URIEncoding="UTF-8" or useBodyEncodingForURI ="true" to server.xml was the right solution for Tomcat 7. Also, upgrading to Tomcat 8 solves everything without a need to add above codes.
According to this link, "In Tomcat 8 starting with 8.0.0 (8.0.0-RC3, to be specific), default value (strict compliance is off) of URIEncoding is now UTF-8."

Lesson to be learned: As a end-user, always use some recent versions but not exactly latest one. I had another experience of problem with Tomcat some time ago. After searching a lot, I understood that it is because of some new feature in Tomcat, and so, there is no document for problem available or a solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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