You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jens Hagel <ha...@gmail.com> on 2007/11/07 14:40:25 UTC

Comet: response.sendRedirect() Problem

Hello,

I'm trying to use the sendRedirect() function in the begin event of a
simple CometServlet,
but nothing happens. Does anyone has an idea what's going wrong?

kind regards,
jens hagel

------------------
import org.apache.catalina.CometProcessor;
import org.apache.catalina.CometEvent;

import javax.servlet.http.*;
import javax.servlet.ServletException;
import java.io.IOException;

public class CometServlet extends HttpServlet implements CometProcessor {

    public void event(CometEvent cometEvent) throws IOException,
ServletException {

        HttpServletResponse response = cometEvent.getHttpServletResponse();

        // don't want timeout events
        cometEvent.setTimeout(1000000);

        if (cometEvent.getEventType() == CometEvent.EventType.BEGIN) {

            log("Begin for session");
            response.sendRedirect("http://www.heise.de");
            cometEvent.close();

        } else if (cometEvent.getEventType() == CometEvent.EventType.ERROR) {
            log("Error for session: " + cometEvent.getEventSubType());
            cometEvent.close();
        } else if (cometEvent.getEventType() == CometEvent.EventType.END) {
            log("End for session");
            cometEvent.close();
        } else if (cometEvent.getEventType() == CometEvent.EventType.READ) {
            log("Read for session");
        }
    }
}
-----------------

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


Re: Comet: response.sendRedirect() Problem

Posted by Jens Hagel <ha...@gmail.com>.
Hello Filip,

I've tried it with the current release candidate but still nothing happens.

jens


On Nov 7, 2007 6:13 PM, Filip Hanik - Dev Lists <de...@hanik.com> wrote:
> there is a bug in 6.0.14 regarding pipelining HTTP events on a comet
> connection, your code is correct, try with our current release candidate
> http://people.apache.org/~remm/tomcat-6/v6.0.15/bin/
>
> Filip
>
>
> Jens Hagel wrote:
> > Hello,
> >
> > I'm trying to use the sendRedirect() function in the begin event of a
> > simple CometServlet,
> > but nothing happens. Does anyone has an idea what's going wrong?
> >
> > kind regards,
> > jens hagel
> >
> > ------------------
> > import org.apache.catalina.CometProcessor;
> > import org.apache.catalina.CometEvent;
> >
> > import javax.servlet.http.*;
> > import javax.servlet.ServletException;
> > import java.io.IOException;
> >
> > public class CometServlet extends HttpServlet implements CometProcessor {
> >
> >     public void event(CometEvent cometEvent) throws IOException,
> > ServletException {
> >
> >         HttpServletResponse response = cometEvent.getHttpServletResponse();
> >
> >         // don't want timeout events
> >         cometEvent.setTimeout(1000000);
> >
> >         if (cometEvent.getEventType() == CometEvent.EventType.BEGIN) {
> >
> >             log("Begin for session");
> >             response.sendRedirect("http://www.heise.de");
> >             cometEvent.close();
> >
> >         } else if (cometEvent.getEventType() == CometEvent.EventType.ERROR) {
> >             log("Error for session: " + cometEvent.getEventSubType());
> >             cometEvent.close();
> >         } else if (cometEvent.getEventType() == CometEvent.EventType.END) {
> >             log("End for session");
> >             cometEvent.close();
> >         } else if (cometEvent.getEventType() == CometEvent.EventType.READ) {
> >             log("Read for session");
> >         }
> >     }
> > }
> > -----------------
> >
> > ---------------------------------------------------------------------
> > To start a new topic, e-mail: users@tomcat.apache.org
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

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


Re: Comet: response.sendRedirect() Problem

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
Jens Hagel wrote:
> Hi filip, i've patched my Tomcat.
> Now, it works! Thank you! ;-)
>   
you're welcome, this will also be included in the next release
Filip
> regards,
> jens
>
> On Nov 14, 2007 6:21 PM, Filip Hanik - Dev Lists <de...@hanik.com> wrote:
>   
>> hi Jens,
>> you've uncovered a bug in Tomcat. basically, Tomcat doesn't respect that
>> you are calling CometEvent.close upon the BEGIN event.
>> I've proposed a fix
>> http://svn.apache.org/viewvc?view=rev&revision=594957
>>
>> and if it is accepted it will be included in our next release which
>> should be within a short timeframe.
>> if you want to patch your Tomcat, the patch is at
>> http://people.apache.org/~fhanik/patches/comet-begin-event-close.patch
>>
>> Filip
>>
>> Jens Hagel wrote:
>>     
>>> hi,
>>>
>>> i'm implementing comet support for different servlet containers in an
>>> ajax framework.
>>> with jetty and glassfish comet support it works very well, but with
>>> tomcat something
>>> is going wrong with the Servlet API sendRedirect()- function which i
>>> cannot figure out.
>>>
>>> do you have an idea what's going wrong?
>>>
>>> thank you!
>>>
>>> regards,
>>> jens
>>>
>>>
>>>       
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>     
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
>   


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


Re: Comet: response.sendRedirect() Problem

Posted by Jens Hagel <ha...@gmail.com>.
Hi filip, i've patched my Tomcat.
Now, it works! Thank you! ;-)

regards,
jens

On Nov 14, 2007 6:21 PM, Filip Hanik - Dev Lists <de...@hanik.com> wrote:
> hi Jens,
> you've uncovered a bug in Tomcat. basically, Tomcat doesn't respect that
> you are calling CometEvent.close upon the BEGIN event.
> I've proposed a fix
> http://svn.apache.org/viewvc?view=rev&revision=594957
>
> and if it is accepted it will be included in our next release which
> should be within a short timeframe.
> if you want to patch your Tomcat, the patch is at
> http://people.apache.org/~fhanik/patches/comet-begin-event-close.patch
>
> Filip
>
> Jens Hagel wrote:
> > hi,
> >
> > i'm implementing comet support for different servlet containers in an
> > ajax framework.
> > with jetty and glassfish comet support it works very well, but with
> > tomcat something
> > is going wrong with the Servlet API sendRedirect()- function which i
> > cannot figure out.
> >
> > do you have an idea what's going wrong?
> >
> > thank you!
> >
> > regards,
> > jens
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

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


Re: Comet: response.sendRedirect() Problem

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
hi Jens,
you've uncovered a bug in Tomcat. basically, Tomcat doesn't respect that 
you are calling CometEvent.close upon the BEGIN event.
I've proposed a fix
http://svn.apache.org/viewvc?view=rev&revision=594957

and if it is accepted it will be included in our next release which 
should be within a short timeframe.
if you want to patch your Tomcat, the patch is at
http://people.apache.org/~fhanik/patches/comet-begin-event-close.patch

Filip

Jens Hagel wrote:
> hi,
>
> i'm implementing comet support for different servlet containers in an
> ajax framework.
> with jetty and glassfish comet support it works very well, but with
> tomcat something
> is going wrong with the Servlet API sendRedirect()- function which i
> cannot figure out.
>
> do you have an idea what's going wrong?
>
> thank you!
>
> regards,
> jens
>
>   


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


Re: Comet: response.sendRedirect() Problem

Posted by Jens Hagel <ha...@gmail.com>.
hi,

i'm implementing comet support for different servlet containers in an
ajax framework.
with jetty and glassfish comet support it works very well, but with
tomcat something
is going wrong with the Servlet API sendRedirect()- function which i
cannot figure out.

do you have an idea what's going wrong?

thank you!

regards,
jens



On Nov 7, 2007 6:13 PM, Filip Hanik - Dev Lists <de...@hanik.com> wrote:
> there is a bug in 6.0.14 regarding pipelining HTTP events on a comet
> connection, your code is correct, try with our current release candidate
> http://people.apache.org/~remm/tomcat-6/v6.0.15/bin/
>
> Filip
>
>
> Jens Hagel wrote:
> > Hello,
> >
> > I'm trying to use the sendRedirect() function in the begin event of a
> > simple CometServlet,
> > but nothing happens. Does anyone has an idea what's going wrong?
> >
> > kind regards,
> > jens hagel
> >
> > ------------------
> > import org.apache.catalina.CometProcessor;
> > import org.apache.catalina.CometEvent;
> >
> > import javax.servlet.http.*;
> > import javax.servlet.ServletException;
> > import java.io.IOException;
> >
> > public class CometServlet extends HttpServlet implements CometProcessor {
> >
> >     public void event(CometEvent cometEvent) throws IOException,
> > ServletException {
> >
> >         HttpServletResponse response = cometEvent.getHttpServletResponse();
> >
> >         // don't want timeout events
> >         cometEvent.setTimeout(1000000);
> >
> >         if (cometEvent.getEventType() == CometEvent.EventType.BEGIN) {
> >
> >             log("Begin for session");
> >             response.sendRedirect("http://www.heise.de");
> >             cometEvent.close();
> >
> >         } else if (cometEvent.getEventType() == CometEvent.EventType.ERROR) {
> >             log("Error for session: " + cometEvent.getEventSubType());
> >             cometEvent.close();
> >         } else if (cometEvent.getEventType() == CometEvent.EventType.END) {
> >             log("End for session");
> >             cometEvent.close();
> >         } else if (cometEvent.getEventType() == CometEvent.EventType.READ) {
> >             log("Read for session");
> >         }
> >     }
> > }
> > -----------------
> >
> > ---------------------------------------------------------------------
> > To start a new topic, e-mail: users@tomcat.apache.org
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

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


Re: Comet: response.sendRedirect() Problem

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
there is a bug in 6.0.14 regarding pipelining HTTP events on a comet 
connection, your code is correct, try with our current release candidate
http://people.apache.org/~remm/tomcat-6/v6.0.15/bin/

Filip

Jens Hagel wrote:
> Hello,
>
> I'm trying to use the sendRedirect() function in the begin event of a
> simple CometServlet,
> but nothing happens. Does anyone has an idea what's going wrong?
>
> kind regards,
> jens hagel
>
> ------------------
> import org.apache.catalina.CometProcessor;
> import org.apache.catalina.CometEvent;
>
> import javax.servlet.http.*;
> import javax.servlet.ServletException;
> import java.io.IOException;
>
> public class CometServlet extends HttpServlet implements CometProcessor {
>
>     public void event(CometEvent cometEvent) throws IOException,
> ServletException {
>
>         HttpServletResponse response = cometEvent.getHttpServletResponse();
>
>         // don't want timeout events
>         cometEvent.setTimeout(1000000);
>
>         if (cometEvent.getEventType() == CometEvent.EventType.BEGIN) {
>
>             log("Begin for session");
>             response.sendRedirect("http://www.heise.de");
>             cometEvent.close();
>
>         } else if (cometEvent.getEventType() == CometEvent.EventType.ERROR) {
>             log("Error for session: " + cometEvent.getEventSubType());
>             cometEvent.close();
>         } else if (cometEvent.getEventType() == CometEvent.EventType.END) {
>             log("End for session");
>             cometEvent.close();
>         } else if (cometEvent.getEventType() == CometEvent.EventType.READ) {
>             log("Read for session");
>         }
>     }
> }
> -----------------
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
>   


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