After closer inspection, I noticed that with the original code (as 
outlined below), the first visit to the page gets me one JSESSIONID 
cookie with a path of "/cocoon". As soon as I begin to browse around on 
the site, the request object passed into the filter now has a JSESSIONID 
cookie, and the correct path is assigned through the wrapper; this 
effectively creates two cookies (one for each path).  If I end my 
session, it always creates the cookie with path "/cocoon" first, and 
then creates the second cookie only when I click around. My question is, 
why isn't this cookie added via the RequestWrapper the first time around?

Also. I have a cookie of my own that I use for the site, and I set the 
path to "/" through Cookie.setPath(). This works fine until I try using 
the RequestWrapper; now, when the addCookie() method gets called, the 
supplied cookie has a path of null. The effect of this is that the 
current directory is assigned to the path, and I have as many cookies 
with this name as I have directories that I've visited. What could be 
causing this, and how could I resolve it?

Thanks again for the continued assistance, it's much appreciated.

Liam Morley

Christoph Gaffga wrote:

>It think that when your webapp is under webapps/cocoon, the cookie-Path is
>alway /cocoon.
>If you don't want that, then you could run your webapp as webapps/ROOT (your
>cookie-path will be /).
>
>For me that's no enought. I modify the JSESSIONID-cookie (and the path) in
>the following way:
>
>I've the following in my WEB-INF/web.xml-File
>
>  <filter>
>    <filter-name>RequestWrapper</filter-name>
>    <filter-class>com.triplemind.asp.server.RequestWrapper</filter-class>
>  </filter>
>  <filter-mapping>
>    <filter-name>RequestWrapper</filter-name>
>    <servlet-name>Cocoon2</servlet-name>
>  </filter-mapping>
>
>so that every request to cocoon goes through my RequestWrapper-Class.
>In my RequestWrapper I can change the cookies.
>
>public class RequestWrapper implements Filter {
>   ...
>   public void doFilter(ServletRequest request,
>                        ServletResponse response, FilterChain chain) {
>     if(request instanceof HttpServletRequest && response instanceof
>HttpServletResponse) {
>        response = new MyHttpResponseWrapper(response);
>     }
>     chain.doFilter(request, response);
>   }
>   ...
> }
>
>
>public class MyHttpResponseWrapper extends HttpServletResponseWrapper {
>  public void addCookie(Cookie cookie) {
>    if(cookie.getName().equals("JSESSIONID")) {
>      cookie.setPath("/whereever-you-want/dir/");
>      cookie.setDomain("mydomain.com");
>      // you can also set expiry, etc...
>    }
>    super.addCookie(cookie);
>  }
>
>}
>
>
>yours
>Christoph Gaffga
>[EMAIL PROTECTED]
>
>
>
>----- Original Message -----
>From: "Liam Morley" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Friday, June 14, 2002 4:39 PM
>Subject: Re: JSESSIONID had /cocoon as path
>
>
>  
>
>>This is new to me. Would you by any chance mind explaining more in
>>depth? I'm trying to rewrite the URL so that cocoon is not in the URL,
>>but then sessions don't work..
>>
>>Thank you very much,
>>Liam Morley
>>
>>Christoph Gaffga wrote:
>>
>>    
>>
>>>Hi, i'm looking for a way to change the cookie path also.
>>>At the Moment I'm using a filter-Class infront of
>>>the cocoon-Servlet and wrap the ServletResponse, but it
>>>would be nice to just edit the config file.
>>>
>>>Christoph Gaffga
>>>[EMAIL PROTECTED]
>>>
>>>
>>>----- Original Message -----
>>>From: "Liam Morley" <[EMAIL PROTECTED]>
>>>To: <[EMAIL PROTECTED]>
>>>Sent: Friday, June 14, 2002 4:21 PM
>>>Subject: JSESSIONID had /cocoon as path
>>>
>>>
>>>
>>>
>>>      
>>>
>>>>Is there a way to edit the path for the JSESSIONID cookie?
>>>>
>>>>Thanks,
>>>>Liam Morley
>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>Please check that your question  has not already been answered in the
>>>>FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
>>>>
>>>>To unsubscribe, e-mail:     <[EMAIL PROTECTED]>
>>>>For additional commands, e-mail:   <[EMAIL PROTECTED]>
>>>>
>>>>
>>>>        
>>>>
>>>---------------------------------------------------------------------
>>>Please check that your question  has not already been answered in the
>>>FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
>>>
>>>To unsubscribe, e-mail:     <[EMAIL PROTECTED]>
>>>For additional commands, e-mail:   <[EMAIL PROTECTED]>
>>>
>>>
>>>
>>>
>>>
>>>      
>>>
>
>
>
>  
>



---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>

Reply via email to