You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Johan Compagner <jc...@servoy.com> on 2018/11/22 16:06:02 UTC

javax.websocket.Session.getRequestParameterMap() encoding

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

Re: javax.websocket.Session.getRequestParameterMap() encoding

Posted by Mark Thomas <ma...@apache.org>.
On 22/11/2018 21:29, Johan Compagner wrote:
> Op do 22 nov. 2018 22:05 schreef Mark Thomas <markt@apache.org:
> 
>> On 22/11/2018 16:06, Johan Compagner wrote
>>>
>>> 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
>>
> 
> 
> 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-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: javax.websocket.Session.getRequestParameterMap() encoding

Posted by Johan Compagner <jc...@servoy.com>.
Op do 22 nov. 2018 22:05 schreef Mark Thomas <markt@apache.org:

> On 22/11/2018 16:06, Johan Compagner wrote
> >
> > 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
>


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?



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

Re: javax.websocket.Session.getRequestParameterMap() encoding

Posted by Mark Thomas <ma...@apache.org>.
On 22/11/2018 16:06, Johan Compagner wrote:
> 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"

Tomcat version?

See URIEncoding for the Connector.

> 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?

Several options:
- configure the connector
- use a filter before the request reached the WebSocket filter

Mark

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