You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Michael Farah <an...@gmail.com> on 2009/03/09 06:58:05 UTC

Cookie not being set

Hi all

I’m running two web apps off a single instance of Tomcat 6.0.1.8 on a CentOS
64 bit OS. Tomcat is fronted with Apache 2.2 and I’m using mod_proxy_http.
Both applications are wap sites.

I’ve been trying to implement an analytics solution provided by Admob. The
solution uses a pixel image in conjunction with a  cookie to provide
detailed user info. Similar to Google analytics but without the Javascript.
Admob provides the code in multiple formats including Java.
The problem is that the cookie is not being set. I have been back and forth
with Admob and they are adamant that the problem lies in our enviroment.
Below is my Virtual Host config;

<VirtualHost 211.111.111.111:80>
    ServerName sitea.com
    ServerAlias www.sitea.com 
    DocumentRoot /home/sitea
    ProxyPass / http://tomcatserver.com:8080/sitea/
    ProxyPassReverse / http://tomcatserver.com:8080/sitea/
    ProxyPassReverseCookieDomain tomcatserver.com site.com
</VirtualHost>

The Admob code is a JSP file named AdMob.jsp that is imported into each page
of our webapp via this code snippet
<jsp:include page="/AdMob.jsp"/>

The AdMob.jsp file is pretty big so I won’t pase it all here except for two
snippets which I feel are most relevant. The first is this one;

admobRequiredParams.put("COOKIE_DOMAIN", "sitea.com"); // If your mobile
site uses multiple subdomains, replace "null" with your root domain (e.g.
"example.com") to make the AdMob cookie visible across subdomains.

The second is the code that sets the cookie;

private String admobGetCookieValue(HttpServletRequest request,
HttpServletResponse response, PageContext pageContext, String cookieDomain)
{
  try {
    Cookie cookies[] = request.getCookies();
    if (cookies != null) {
      for (int i = 0; i < cookies.length; i++) {
        if (cookies[i].getName().equals("admobuu")) return
cookies[i].getValue();
      }
    }
    
    // Set a cookie if one has not already been set
    if (pageContext.getAttribute("admobCookie") == null) {
      String value = UUID.randomUUID().toString().replace("-","");
      Cookie c = new Cookie("admobuu", value);
      c.setMaxAge(60*60*24*365*20);
      c.setPath("/");
      if (cookieDomain != null) {
        if (cookieDomain.charAt(0) != '.') cookieDomain = "." +
cookieDomain;
        c.setDomain(cookieDomain);
      }
      response.addCookie(c);
      pageContext.setAttribute("admobCookie", value);
    }
    return (String)pageContext.getAttribute("admobCookie");
  }
  catch (Exception e) {
    return "";
  }
}

When accessing sitea.com via Firefox with Live HTTP headers, it’s clear that
the cookie is not being set as it doesn’t come shop up. However there is
another cookie being set which I don’t recognise;

Cookie: an=Af4ab27e8d16fb4ac50f73d03fe54c132

Can anyone please assist in explaining why this AdMob cookie is not being
set?

Thanks in advance
Michael



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


Fwd: Cookie not being set

Posted by Andromeda Mobile <an...@gmail.com>.
My apologies for re-submitting this but I'm getting a little desperate
here. If no one here can assist can anyone suggest where else I could
go for help?


---------- Forwarded message ----------
From: Michael Farah <an...@gmail.com>
Date: Mon, Mar 9, 2009 at 7:58 AM
Subject: Cookie not being set
To: users@tomcat.apache.org


Hi all

I’m running two web apps off a single instance of Tomcat 6.0.1.8 on a CentOS
64 bit OS. Tomcat is fronted with Apache 2.2 and I’m using mod_proxy_http.
Both applications are wap sites.

I’ve been trying to implement an analytics solution provided by Admob. The
solution uses a pixel image in conjunction with a  cookie to provide
detailed user info. Similar to Google analytics but without the Javascript.
Admob provides the code in multiple formats including Java.
The problem is that the cookie is not being set. I have been back and forth
with Admob and they are adamant that the problem lies in our enviroment.
Below is my Virtual Host config;

<VirtualHost 211.111.111.111:80>
    ServerName sitea.com
    ServerAlias www.sitea.com
    DocumentRoot /home/sitea
    ProxyPass / http://tomcatserver.com:8080/sitea/
    ProxyPassReverse / http://tomcatserver.com:8080/sitea/
    ProxyPassReverseCookieDomain tomcatserver.com site.com
</VirtualHost>

The Admob code is a JSP file named AdMob.jsp that is imported into each page
of our webapp via this code snippet
<jsp:include page="/AdMob.jsp"/>

The AdMob.jsp file is pretty big so I won’t pase it all here except for two
snippets which I feel are most relevant. The first is this one;

admobRequiredParams.put("COOKIE_DOMAIN", "sitea.com"); // If your mobile
site uses multiple subdomains, replace "null" with your root domain (e.g.
"example.com") to make the AdMob cookie visible across subdomains.

The second is the code that sets the cookie;

private String admobGetCookieValue(HttpServletRequest request,
HttpServletResponse response, PageContext pageContext, String cookieDomain)
{
  try {
    Cookie cookies[] = request.getCookies();
    if (cookies != null) {
      for (int i = 0; i < cookies.length; i++) {
        if (cookies[i].getName().equals("admobuu")) return
cookies[i].getValue();
      }
    }

    // Set a cookie if one has not already been set
    if (pageContext.getAttribute("admobCookie") == null) {
      String value = UUID.randomUUID().toString().replace("-","");
      Cookie c = new Cookie("admobuu", value);
      c.setMaxAge(60*60*24*365*20);
      c.setPath("/");
      if (cookieDomain != null) {
        if (cookieDomain.charAt(0) != '.') cookieDomain = "." +
cookieDomain;
        c.setDomain(cookieDomain);
      }
      response.addCookie(c);
      pageContext.setAttribute("admobCookie", value);
    }
    return (String)pageContext.getAttribute("admobCookie");
  }
  catch (Exception e) {
    return "";
  }
}

When accessing sitea.com via Firefox with Live HTTP headers, it’s clear that
the cookie is not being set as it doesn’t come shop up. However there is
another cookie being set which I don’t recognise;

Cookie: an=Af4ab27e8d16fb4ac50f73d03fe54c132

Can anyone please assist in explaining why this AdMob cookie is not being
set?

Thanks in advance
Michael

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


Fwd: Cookie not being set

Posted by Andromeda Mobile <an...@gmail.com>.
Does anyone have any idea on the query below?


---------- Forwarded message ----------
From: Michael Farah <an...@gmail.com>
Date: Mon, Mar 9, 2009 at 7:58 AM
Subject: Cookie not being set
To: users@tomcat.apache.org


Hi all

I’m running two web apps off a single instance of Tomcat 6.0.1.8 on a CentOS
64 bit OS. Tomcat is fronted with Apache 2.2 and I’m using mod_proxy_http.
Both applications are wap sites.

I’ve been trying to implement an analytics solution provided by Admob. The
solution uses a pixel image in conjunction with a  cookie to provide
detailed user info. Similar to Google analytics but without the Javascript.
Admob provides the code in multiple formats including Java.
The problem is that the cookie is not being set. I have been back and forth
with Admob and they are adamant that the problem lies in our enviroment.
Below is my Virtual Host config;

<VirtualHost 211.111.111.111:80>
    ServerName sitea.com
    ServerAlias www.sitea.com
    DocumentRoot /home/sitea
    ProxyPass / http://tomcatserver.com:8080/sitea/
    ProxyPassReverse / http://tomcatserver.com:8080/sitea/
    ProxyPassReverseCookieDomain tomcatserver.com site.com
</VirtualHost>

The Admob code is a JSP file named AdMob.jsp that is imported into each page
of our webapp via this code snippet
<jsp:include page="/AdMob.jsp"/>

The AdMob.jsp file is pretty big so I won’t pase it all here except for two
snippets which I feel are most relevant. The first is this one;

admobRequiredParams.put("COOKIE_DOMAIN", "sitea.com"); // If your mobile
site uses multiple subdomains, replace "null" with your root domain (e.g.
"example.com") to make the AdMob cookie visible across subdomains.

The second is the code that sets the cookie;

private String admobGetCookieValue(HttpServletRequest request,
HttpServletResponse response, PageContext pageContext, String cookieDomain)
{
  try {
    Cookie cookies[] = request.getCookies();
    if (cookies != null) {
      for (int i = 0; i < cookies.length; i++) {
        if (cookies[i].getName().equals("admobuu")) return
cookies[i].getValue();
      }
    }

    // Set a cookie if one has not already been set
    if (pageContext.getAttribute("admobCookie") == null) {
      String value = UUID.randomUUID().toString().replace("-","");
      Cookie c = new Cookie("admobuu", value);
      c.setMaxAge(60*60*24*365*20);
      c.setPath("/");
      if (cookieDomain != null) {
        if (cookieDomain.charAt(0) != '.') cookieDomain = "." +
cookieDomain;
        c.setDomain(cookieDomain);
      }
      response.addCookie(c);
      pageContext.setAttribute("admobCookie", value);
    }
    return (String)pageContext.getAttribute("admobCookie");
  }
  catch (Exception e) {
    return "";
  }
}

When accessing sitea.com via Firefox with Live HTTP headers, it’s clear that
the cookie is not being set as it doesn’t come shop up. However there is
another cookie being set which I don’t recognise;

Cookie: an=Af4ab27e8d16fb4ac50f73d03fe54c132

Can anyone please assist in explaining why this AdMob cookie is not being
set?

Thanks in advance
Michael

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


Re: Fwd: Cookie not being set

Posted by André Warnier <aw...@ice-sa.com>.
Andromeda Mobile wrote:
> Thanks guys for your help. By moving the jsp include to the head of
> the document I was able to get the set cookie working so it was to do
> with the fact that the cookie needed to be sent before any other
> output was streamed.
> 
Just my didactic streak at play :

Think of it this way :
A HTTP response looks like this :

200 OK     (HTTP status line)
header line 1
header line 2
... more header lines, like "Set-Cookie: .."
(one blank line)
Content
...

On the wire, the 200 OK is the first one to go out, followed by the
first header line, etc.

Tomcat composes the status line and the header lines, but holds on to
them as long as it can, while it is creating the content.  As long as it
has not yet output the first byte of the content, you can still change
the headers.  But as soon as Tomcat has to output the first byte of the
content, it has to output the status line, and the header lines, and the
blank line first, before the first content byte.
Thus, as soon as the first content byte goes out, the headers are
already out, and it is too late to change them.




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


Fwd: Cookie not being set

Posted by Andromeda Mobile <an...@gmail.com>.
Thanks guys for your help. By moving the jsp include to the head of
the document I was able to get the set cookie working so it was to do
with the fact that the cookie needed to be sent before any other
output was streamed.


---------- Forwarded message ----------
From: Michael Farah <an...@gmail.com>
Date: Mon, Mar 9, 2009 at 7:58 AM
Subject: Cookie not being set
To: users@tomcat.apache.org


Hi all

I’m running two web apps off a single instance of Tomcat 6.0.1.8 on a CentOS
64 bit OS. Tomcat is fronted with Apache 2.2 and I’m using mod_proxy_http.
Both applications are wap sites.

I’ve been trying to implement an analytics solution provided by Admob. The
solution uses a pixel image in conjunction with a  cookie to provide
detailed user info. Similar to Google analytics but without the Javascript.
Admob provides the code in multiple formats including Java.
The problem is that the cookie is not being set. I have been back and forth
with Admob and they are adamant that the problem lies in our enviroment.
Below is my Virtual Host config;

<VirtualHost 211.111.111.111:80>
    ServerName sitea.com
    ServerAlias www.sitea.com
    DocumentRoot /home/sitea
    ProxyPass / http://tomcatserver.com:8080/sitea/
    ProxyPassReverse / http://tomcatserver.com:8080/sitea/
    ProxyPassReverseCookieDomain tomcatserver.com site.com
</VirtualHost>

The Admob code is a JSP file named AdMob.jsp that is imported into each page
of our webapp via this code snippet
<jsp:include page="/AdMob.jsp"/>

The AdMob.jsp file is pretty big so I won’t pase it all here except for two
snippets which I feel are most relevant. The first is this one;

admobRequiredParams.put("COOKIE_DOMAIN", "sitea.com"); // If your mobile
site uses multiple subdomains, replace "null" with your root domain (e.g.
"example.com") to make the AdMob cookie visible across subdomains.

The second is the code that sets the cookie;

private String admobGetCookieValue(HttpServletRequest request,
HttpServletResponse response, PageContext pageContext, String cookieDomain)
{
  try {
    Cookie cookies[] = request.getCookies();
    if (cookies != null) {
      for (int i = 0; i < cookies.length; i++) {
        if (cookies[i].getName().equals("admobuu")) return
cookies[i].getValue();
      }
    }

    // Set a cookie if one has not already been set
    if (pageContext.getAttribute("admobCookie") == null) {
      String value = UUID.randomUUID().toString().replace("-","");
      Cookie c = new Cookie("admobuu", value);
      c.setMaxAge(60*60*24*365*20);
      c.setPath("/");
      if (cookieDomain != null) {
        if (cookieDomain.charAt(0) != '.') cookieDomain = "." +
cookieDomain;
        c.setDomain(cookieDomain);
      }
      response.addCookie(c);
      pageContext.setAttribute("admobCookie", value);
    }
    return (String)pageContext.getAttribute("admobCookie");
  }
  catch (Exception e) {
    return "";
  }
}

When accessing sitea.com via Firefox with Live HTTP headers, it’s clear that
the cookie is not being set as it doesn’t come shop up. However there is
another cookie being set which I don’t recognise;

Cookie: an=Af4ab27e8d16fb4ac50f73d03fe54c132

Can anyone please assist in explaining why this AdMob cookie is not being
set?

Thanks in advance
Michael

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


Re: Cookie not being set

Posted by André Warnier <aw...@ice-sa.com>.
Peter Crowther wrote:
>> From: Andromeda Mobile [mailto:andromedamobile@gmail.com]
>> I tried moving the include to the head of my document but this does
>> not appear to have made any difference. Must it be in the head or
>> should it be even above this?
> 
> Ideally it would be wherever AdMob's documentation says it should appear, as I would assume they have at least tested their JSP implementation in the popular servlet containers.  Where does it suggest?
> 
> Assuming the JSP emits the HTML markup for an image at whatever point it is included, the earliest realistic point to include it would be after the body tag.
> 
This is a bit of a shot from the hip, but I think that if you are trying 
to set this cookie header too late in the cycle, you may get some error 
message in the logs like "response already committed".  It's probably 
worth checking anyway.

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


RE: Cookie not being set

Posted by Peter Crowther <Pe...@melandra.com>.
> From: Andromeda Mobile [mailto:andromedamobile@gmail.com]
> I tried moving the include to the head of my document but this does
> not appear to have made any difference. Must it be in the head or
> should it be even above this?

Ideally it would be wherever AdMob's documentation says it should appear, as I would assume they have at least tested their JSP implementation in the popular servlet containers.  Where does it suggest?

Assuming the JSP emits the HTML markup for an image at whatever point it is included, the earliest realistic point to include it would be after the body tag.

                - Peter

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


Re: Cookie not being set

Posted by Andromeda Mobile <an...@gmail.com>.
I tried moving the include to the head of my document but this does
not appear to have made any difference. Must it be in the head or
should it be even above this?

On Wed, Mar 11, 2009 at 2:16 PM, David Smith <dn...@cornell.edu> wrote:
> Cookies are sent in the header and tomcat does not wait for the entire
> body of the response before starting to send.  It just waits for a
> buffer to fill up and sends as soon as that occurs.  You should be
> setting the cookie asap or at least before the first block of response
> goes out on the wire.
>
> --David
>
> Andromeda Mobile wrote:
>> Hi Peter
>>
>> The include is actually in the body of the document, right at the
>> bottom! The thing is the code creates a pixel image and so i wanted to
>> put this in an area which would not impact the rest of the page. So
>> should the include be in the head? Do you think this could be the
>> cause?
>>
>> Regards
>> Michael
>>
>> On Wed, Mar 11, 2009 at 1:44 PM, Peter Crowther
>> <Pe...@melandra.com> wrote:
>>
>>>> From: Michael Farah <an...@gmail.com>
>>>> The Admob code is a JSP file named AdMob.jsp that is imported
>>>> into each page
>>>> of our webapp via this code snippet
>>>> <jsp:include page="/AdMob.jsp"/>
>>>>
>>> [...]
>>>
>>>>       response.addCookie(c);
>>>>
>>> Just a thought... where's your include?  In order to add the cookie (which must go in the header), I think no bytes of response must have been sent yet - is the include far enough up the file that this is the case?
>>>
>>> Or someone more experienced will tell me this isn't a problem with servlets :-).
>>>
>>>                - Peter
>>>
>>>
>
>
> ---------------------------------------------------------------------
> 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


Re: Cookie not being set

Posted by David Smith <dn...@cornell.edu>.
Cookies are sent in the header and tomcat does not wait for the entire
body of the response before starting to send.  It just waits for a
buffer to fill up and sends as soon as that occurs.  You should be
setting the cookie asap or at least before the first block of response
goes out on the wire.

--David

Andromeda Mobile wrote:
> Hi Peter
>
> The include is actually in the body of the document, right at the
> bottom! The thing is the code creates a pixel image and so i wanted to
> put this in an area which would not impact the rest of the page. So
> should the include be in the head? Do you think this could be the
> cause?
>
> Regards
> Michael
>
> On Wed, Mar 11, 2009 at 1:44 PM, Peter Crowther
> <Pe...@melandra.com> wrote:
>   
>>> From: Michael Farah <an...@gmail.com>
>>> The Admob code is a JSP file named AdMob.jsp that is imported
>>> into each page
>>> of our webapp via this code snippet
>>> <jsp:include page="/AdMob.jsp"/>
>>>       
>> [...]
>>     
>>>       response.addCookie(c);
>>>       
>> Just a thought... where's your include?  In order to add the cookie (which must go in the header), I think no bytes of response must have been sent yet - is the include far enough up the file that this is the case?
>>
>> Or someone more experienced will tell me this isn't a problem with servlets :-).
>>
>>                - Peter
>>
>>     


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


Re: Cookie not being set

Posted by Andromeda Mobile <an...@gmail.com>.
Hi Peter

The include is actually in the body of the document, right at the
bottom! The thing is the code creates a pixel image and so i wanted to
put this in an area which would not impact the rest of the page. So
should the include be in the head? Do you think this could be the
cause?

Regards
Michael

On Wed, Mar 11, 2009 at 1:44 PM, Peter Crowther
<Pe...@melandra.com> wrote:
>> From: Michael Farah <an...@gmail.com>
>> The Admob code is a JSP file named AdMob.jsp that is imported
>> into each page
>> of our webapp via this code snippet
>> <jsp:include page="/AdMob.jsp"/>
> [...]
>>       response.addCookie(c);
>
> Just a thought... where's your include?  In order to add the cookie (which must go in the header), I think no bytes of response must have been sent yet - is the include far enough up the file that this is the case?
>
> Or someone more experienced will tell me this isn't a problem with servlets :-).
>
>                - Peter
>
> ---------------------------------------------------------------------
> 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


RE: Cookie not being set

Posted by Peter Crowther <Pe...@melandra.com>.
> From: Michael Farah <an...@gmail.com>
> The Admob code is a JSP file named AdMob.jsp that is imported
> into each page
> of our webapp via this code snippet
> <jsp:include page="/AdMob.jsp"/>
[...]
>       response.addCookie(c);

Just a thought... where's your include?  In order to add the cookie (which must go in the header), I think no bytes of response must have been sent yet - is the include far enough up the file that this is the case?

Or someone more experienced will tell me this isn't a problem with servlets :-).

                - Peter

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


Re: Fwd: Cookie not being set

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Michael,

On 3/11/2009 7:37 AM, Andromeda Mobile wrote:
> <jsp:include page="/AdMob.jsp"/>

[snip]


>       Cookie c = new Cookie("admobuu", value);
>       c.setMaxAge(60*60*24*365*20);
>       c.setPath("/");
>       if (cookieDomain != null) {
>         if (cookieDomain.charAt(0) != '.') cookieDomain = "." +
> cookieDomain;
>         c.setDomain(cookieDomain);
>       }
>       response.addCookie(c);


I'm not sure how anal retentive Tomcat is about adhering to the servlet
spec (these days it's getting a little closer to implementing exactly
what the spec lays out), but this could be a problem:

- From SRV.8.3:

"
[The target servlet of the include method] cannot set headers or call
any method that affects the headers of the response, with the exception
of the HttpServletRequest.getSession() and
HttpServletRequest.getSession(boolean) methods. Any attempt to set the
headers must be ignored, and any call to HttpServletRequest.getSession()
or HttpServletRequest.getSession(boolean) that would require adding a
Cookie response header must throw an IllegalStateException if the
response has been committed.
"

So, that basically says that "includes can't set cookies".

Peter and Andre' have good suggestions about "response already
committed" problems that you should check for in your log files. If
that's what happening, then the headers are being sent before your AdMob
include is being processed, and the headers actually /cannot/ be
modified, whatever Tomcat's adherence to the spec turns out to be.

Try using:

<%@include file="/AdMob.jsp" %>

<%...@include> does a text-inclusion into your JSP /before/ it is compiled.
The included text is therefore considered part of the "main" JSP and
there's no involvement of the RequestDispatcher. When you use
<jsp:include>, you are making a sub-request to another resource in the
webapp and are subject to the rules stated above.

Try switching include mechanisms and see if that helps.

Good luck,
- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkm4PtkACgkQ9CaO5/Lv0PDZ0QCgjT0bgvA9QW1AmNqr0JrNKaj4
4cQAoLuWs7HfJ0oLoVvp1GVz99VbND3g
=Y9fu
-----END PGP SIGNATURE-----

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


Fwd: Cookie not being set

Posted by Andromeda Mobile <an...@gmail.com>.
There was a typo in the code below which has now been corrected


---------- Forwarded message ----------
From: Michael Farah <an...@gmail.com>
Date: Mon, Mar 9, 2009 at 7:58 AM
Subject: Cookie not being set
To: users@tomcat.apache.org


Hi all

I’m running two web apps off a single instance of Tomcat 6.0.1.8 on a CentOS
64 bit OS. Tomcat is fronted with Apache 2.2 and I’m using mod_proxy_http.
Both applications are wap sites.

I’ve been trying to implement an analytics solution provided by Admob. The
solution uses a pixel image in conjunction with a  cookie to provide
detailed user info. Similar to Google analytics but without the Javascript.
Admob provides the code in multiple formats including Java.
The problem is that the cookie is not being set. I have been back and forth
with Admob and they are adamant that the problem lies in our enviroment.
Below is my Virtual Host config;

<VirtualHost 211.111.111.111:80>
    ServerName sitea.com
    ServerAlias www.sitea.com
    DocumentRoot /home/sitea
    ProxyPass / http://tomcatserver.com:8080/sitea/
    ProxyPassReverse / http://tomcatserver.com:8080/sitea/
    ProxyPassReverseCookieDomain tomcatserver.com sitea.com
</VirtualHost>

The Admob code is a JSP file named AdMob.jsp that is imported into each page
of our webapp via this code snippet
<jsp:include page="/AdMob.jsp"/>

The AdMob.jsp file is pretty big so I won’t pase it all here except for two
snippets which I feel are most relevant. The first is this one;

admobRequiredParams.put("COOKIE_DOMAIN", "sitea.com"); // If your mobile
site uses multiple subdomains, replace "null" with your root domain (e.g.
"example.com") to make the AdMob cookie visible across subdomains.

The second is the code that sets the cookie;

private String admobGetCookieValue(HttpServletRequest request,
HttpServletResponse response, PageContext pageContext, String cookieDomain)
{
  try {
    Cookie cookies[] = request.getCookies();
    if (cookies != null) {
      for (int i = 0; i < cookies.length; i++) {
        if (cookies[i].getName().equals("admobuu")) return
cookies[i].getValue();
      }
    }

    // Set a cookie if one has not already been set
    if (pageContext.getAttribute("admobCookie") == null) {
      String value = UUID.randomUUID().toString().replace("-","");
      Cookie c = new Cookie("admobuu", value);
      c.setMaxAge(60*60*24*365*20);
      c.setPath("/");
      if (cookieDomain != null) {
        if (cookieDomain.charAt(0) != '.') cookieDomain = "." +
cookieDomain;
        c.setDomain(cookieDomain);
      }
      response.addCookie(c);
      pageContext.setAttribute("admobCookie", value);
    }
    return (String)pageContext.getAttribute("admobCookie");
  }
  catch (Exception e) {
    return "";
  }
}

When accessing sitea.com via Firefox with Live HTTP headers, it’s clear that
the cookie is not being set as it doesn’t come shop up. However there is
another cookie being set which I don’t recognise;

Cookie: an=Af4ab27e8d16fb4ac50f73d03fe54c132

Can anyone please assist in explaining why this AdMob cookie is not being
set?

Thanks in advance
Michael

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