You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Animesh Sonkar <ak...@gmail.com> on 2010/02/04 13:20:07 UTC

Configuring two connectors and COMET Read event

Hi,
I am developing an apppplication where i need two servlets.
One is a normal Http Servlet and another is a comet servlet.

Now i also need two connectors to be setup in server.xml.
One is a normal HTTP/1.1 connector and another a NIO connector.
I made changes to the server.xml as follows.

server.xml
=================
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

    <Connector port="8081"
protocol="org.apache.coyote.http11.Http11NioProtocol"
connectionTimeout="20000" redirectPort="8444" />

    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
=============================================================


web.xml
================================================
    <servlet>
        <servlet-name>cometServlet</servlet-name>

<servlet-class>com.mycomet.servlet.CometControllerServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>cometServlet</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
=========================================================

I have a simple comet servlet as follows.
====================================
public class CometControllerServlet extends HttpServlet implements
CometProcessor{

    @Override
    public void init(ServletConfig config) throws ServletException {
        super.init(config);
    }

    @Override
    public void event(CometEvent event) throws IOException,
            ServletException {

        HttpServletRequest request = event.getHttpServletRequest();
        HttpServletResponse response = event.getHttpServletResponse();

        if (event.getEventType() == EventType.BEGIN) {
            System.out.println("In begin  ");
        }

        if (event.getEventType() == EventType.READ) {
            System.out.println("In read");
        }

        if (event.getEventType() == EventType.END){
            System.out.println(event.getEventSubType());
            System.out.println("In end");
        }

        if (event.getEventType() == EventType.ERROR){
            System.out.println("In error");
        }
    }
}

=================================================================================
Now my questions are:
1. can i define two connectors the way as mentioned above?
The purpose is top provide noth a NIO connector for comet clients and a
normal connector for normal clients.

2. I am not able to invoke the READ event.  How do i do that?

3. Can i send two HTTP request over the same NIO connection. So in effect
for a client on a sinle connectionthere is one BEGIN event and two read
events.
Is it possible in COMET?

Thanks,
Animesh.

Re: Configuring two connectors and COMET Read event

Posted by Stephen Byrne <st...@lincware.com>.
Animesh Sonkar wrote:
*snip*
> 2. I am not able to invoke the READ event.  How do i do that?

You need to send the HTTP request as chunked data. If you happen to be
using an HttpURLConnection, call setChunkedStreamingMode( 1 ). If you
are taking a lower level approach, (i.e. using sockets), send a header
"Transfer-Encoding: chunked", and send CRLF and flush your stream
between chunks.

*snip*
> Thanks,
> Animesh.


-- 
Stephen Byrne
stephen@lincware.com
(585) 286-5817

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


RE: Configuring two connectors and COMET Read event

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Animesh Sonkar [mailto:aksonkar@gmail.com]
> Subject: Configuring two connectors and COMET Read event
> 
> Now i also need two connectors to be setup in server.xml.

Why do you think that?

> One is a normal HTTP/1.1 connector and another a NIO connector.

Why not just the NIO connector?

> 1. can i define two connectors the way as mentioned above?

Yes, but it's probably pointless.

> The purpose is top provide noth a NIO connector for comet clients and a
> normal connector for normal clients.

Again, why?  Let them both use the NIO connector to avoid having to switch ports on redirects and the like.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.


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