Discussion:
javax.websocket.Session.getRequestParameterMap() encoding
Johan Compagner
2018-11-22 16:06:02 UTC
Permalink
Hi,

If we send have a value that is utf8 url encoded to the websocket:

H%C3%BCnenberg

then somehow tomcat just encodes that using i think "ISO-8859-1"

if we are in a filter or servlet we just do:

request.setCharacterEncoding("UTF8");

and then ask for the parameter map then everything is fine it will be
decoded correctly to HÃŒnenberg

problem is how do we do that in a websocket scenario?

the session object of a WebSocket doesn't have anything for that as far as
i can see
the same goes for ServerEndpointConfig.Configurator using
the modifyHandshake method..
--
Johan Compagner
Servoy
Mark Thomas
2018-11-22 21:05:26 UTC
Permalink
Post by Johan Compagner
Hi,
H%C3%BCnenberg
then somehow tomcat just encodes that using i think "ISO-8859-1"
Tomcat version?

See URIEncoding for the Connector.
Post by Johan Compagner
request.setCharacterEncoding("UTF8");
and then ask for the parameter map then everything is fine it will be
decoded correctly to Hünenberg
problem is how do we do that in a websocket scenario?
Several options:
- configure the connector
- use a filter before the request reached the WebSocket filter

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org
Johan Compagner
2018-11-22 21:29:00 UTC
Permalink
Post by Mark Thomas
Post by Johan Compagner
problem is how do we do that in a websocket scenario?
- configure the connector
- use a filter before the request reached the WebSocket filter
We can't do a Tomcat only version. We don't control deployment, we only can
generate the war file and configure in the web.xml in the war or in code.

But can you add a filler to the same websocket url (let's say /websocket)
And then quickly set the encoding on that request before it upgrades it to
a websocket?
Post by Mark Thomas
Mark
---------------------------------------------------------------------
Mark Thomas
2018-11-22 21:46:52 UTC
Permalink
Post by Johan Compagner
Post by Mark Thomas
Post by Johan Compagner
problem is how do we do that in a websocket scenario?
- configure the connector
- use a filter before the request reached the WebSocket filter
We can't do a Tomcat only version. We don't control deployment, we only can
generate the war file and configure in the web.xml in the war or in code.
But can you add a filler to the same websocket url (let's say /websocket)
And then quickly set the encoding on that request before it upgrades it to
a websocket?
That will work on Tomcat because:
a) Tomcat uses a Filter to redirect requests to WebSocket; and
b) Tomcat puts this filter at the end of the chain to ensure that any
filters that - for example - enforce security run first.

For other containers it will depend on how they do the mapping.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@tomcat.apache.org
For additional commands, e-mail: users-***@tomcat.apache.org

Loading...