A workaround for that problem is that you set a new cookie. Not realy clean,
but working solution:

insert
        Cookie cookie = new Cookie("JSESSIONID",
request.getSession().getId());
        cookie.setPath("/whereever-you-want/dir/");
        cookie.setDomain("mydomain.com");
        response.addCookie(cookie);

before or after doFilter, you have to try.

hope it will work for you.
Christoph Gaffga
[EMAIL PROTECTED]


----- Original Message -----
From: "Liam Morley" <[EMAIL PROTECTED]>
To: "Cocoon Users" <[EMAIL PROTECTED]>
Sent: Tuesday, June 18, 2002 8:04 AM
Subject: Re: JSESSIONID had /cocoon as path


> Thank you very much for the help thus far. I've been able to adapt your
> wrapper method almost verbatim, with a few small changes, but I am still
> having a problem: the MyHttpResponseWrapper.addCookie() method is never
> being called.
>
> First, you mentioned putting the filter in the WEB-INF/web.xml file. The
> Cocoon WEB-INF/web.xml file's DTD was originally
> <http://java.sun.com/j2ee/dtds/web-app_2_2.dtd>; the newest version in
> CVS (located at
>
<http://cvs.apache.org/viewcvs.cgi/xml-cocoon2/src/webapp/WEB-INF/web.xml?re
v=1.14&content-type=text/vnd.viewcvs-markup>)
> still has the same DTD. This DTD does not support the <filter> element.
> The DTD for Tomcat, however, can be found at
> <http://java.sun.com/dtd/web-app_2_3.dtd>, and does support <filter>. I
> tried both putting the <filter> element in $CATALINA_HOME/conf/web.xml
> as well as changing the Cocoon DTD version to match Tomcat's, and
> neither seem to do the trick.
>
> Other edits I made to the code are as follows. I included empty methods
> init(FilterConfig) and destroy() in the RequestWrapper class, and
> included a ResponseWrapper (HttpServletResponse) constructor in the
> ResponseWrapper class (which simply calls the superclass' constructor)..
> I also cast the response object when creating the new ResponseWrapper
> from within the doFilter(...) method.
>
> After making all of these changes and running the code, I can see some
> of it getting executed. RequestWrapper.init() is called when Tomcat
> starts up, and RequestWrapper.doFilter() is called when the page is
> loaded... However, the HttpServletRequest object which is passed to the
> doFilter() method has a getCookies() method that returns null, and the
> addCookie() method is never called.
>
> What exactly calls the addCookie() method? Is that supposed to be
> handled in chain.doFilter()? and where is the cookie? I've tried
> everything I can think of to expose the cookie, but I can't find it.
>
> If you could just please help me during this last leg, I'd be incredibly
> grateful. I'm days away from going live, and without the session
> management that comes along with JSESSIONID, we're in pretty bad shape.
>
> Thanks so much for your help thus far,
> Liam Morley
>
> Of course if others have ideas, they'd be incredibly welcome as well..
>
> 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]>


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