Return-Path: X-Original-To: apmail-tomcat-users-archive@www.apache.org Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CAE10105F9 for ; Fri, 23 Aug 2013 16:04:15 +0000 (UTC) Received: (qmail 89374 invoked by uid 500); 23 Aug 2013 16:04:12 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 89018 invoked by uid 500); 23 Aug 2013 16:04:07 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 89009 invoked by uid 99); 23 Aug 2013 16:04:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Aug 2013 16:04:05 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of toddfas@gmail.com designates 74.125.82.53 as permitted sender) Received: from [74.125.82.53] (HELO mail-wg0-f53.google.com) (74.125.82.53) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Aug 2013 16:04:01 +0000 Received: by mail-wg0-f53.google.com with SMTP id c11so720694wgh.20 for ; Fri, 23 Aug 2013 09:03:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=QZQC5OLPp7SKdH94fyCjDI//wt/hPOLojDn4nJzCsqI=; b=VxxV01PVnNkNWKuSYjarAJX36NapXAK+xwZmvJSVITqKDqqIxU1EK0MUGYP0Dbjbvt I7HEBSyx/7ckgNlCMq+VEitdPzEoaJ14omCtpsKi6FFzBEuMjpE8kmhK7ASpXe/n5sC/ 9cHJOfB9Mc2prUPfF/H7DuWJalrEvS4zngPQm8q7PBBeJMsrjxwukgdXI66QbEdQJV31 q2FZoXvweda8Ax8oZJy3CskpABqfrXgmV1WAzgHbGy0TxuXJTE8DUx/VpOUhOVG8Yo5e It06Cyvv12/6JJJ8TjMvDblR8gj0zJezwnsTjeA40j6wkqV7ceiOu9H24wm+YnbmZzsT 3oLQ== MIME-Version: 1.0 X-Received: by 10.194.250.6 with SMTP id yy6mr369918wjc.13.1377273820654; Fri, 23 Aug 2013 09:03:40 -0700 (PDT) Received: by 10.216.61.79 with HTTP; Fri, 23 Aug 2013 09:03:40 -0700 (PDT) In-Reply-To: References: Date: Fri, 23 Aug 2013 09:03:40 -0700 Message-ID: Subject: Re: Tomcat 8 Websocket API - Cookies & Headers From: toddfas To: Tomcat Users List Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org Thanks very much for the quick response Niki! I went down the configurator path too, but then I could not find a way to pass the cookie values into the ServerEndPoint.onOpen where I need to use it. I tried passing it via session.getRequestParameterMap() but that is a Collections.unmodifiableMap(). In my scenario the session.getHttpSession() is NULL so I can't put it in there. I didn't like the idea of putting it in ThreadLocal (unless I am guaranteed by the spec that ServerEndPoint.onOpen is always called on the same thread that processes the handshake). That was when I started thinking I must be missing something simple. Any suggestions? Thanks, Todd On Thu, Aug 22, 2013 at 10:12 PM, Niki Dokovski wrote: > On Fri, Aug 23, 2013 at 2:58 AM, toddfas wrote: > >> I'm trying to figure out how to get access to the cookies and headers >> passed up in the Websocket handshake request on Tomcat 8. >> >> In Tomcat 7 the whole HttpServletRequest was passed into the >> WebSocketServlet. createWebSocketInbound method so it was easy to grab >> from the request headers. In Tomcat 8 the querystring and URI are both >> exposed by the javax.websocket.Session passed to >> ServerEndPoint.onOpen, but I don't see a mechanism for getting the >> cookies or headers. >> > > You can supply an extension of > http://docs.oracle.com/javaee/7/api/javax/websocket/server/ServerEndpointConfig.Configurator.html > and get > http://docs.oracle.com/javaee/7/api/javax/websocket/server/HandshakeRequest.html > through > modifyHandshake invoked by the container during processing of client 'GET' > handshake message. Handshake request containes methods for inspecting the > http request parameters and headers. > > > >> We are integrating Websocket connections into an existing web app and >> want to use the cookies set by our web app in the Websocket connection >> process. >> >> Thanks for any insight. >> Todd >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org >> For additional commands, e-mail: users-help@tomcat.apache.org >> >> --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org