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.