tomcat comet server deploy?

L

lightning

Are there any differences between the normal servlet's deployment and
the comet servlet's?

Why do I still must implement a doGet method to avoid http405?

And the code in

public void event(CometEvent event) throws IOException,
ServletException

not executed at all??

code:

public class ChatServlet extends HttpServlet implements CometProcessor
{

/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}

/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occure
*/
public void init() throws ServletException {
// Put your code here
}


@Override
protected void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
System.out.println("getgetget");
}

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

log("fefefefefefe");

}

}


web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<description>This is the description of my J2EE component</
description>
<display-name>This is the display name of my J2EE component</
display-name>
<servlet-name>ChatServlet</servlet-name>
<servlet-class>ChatServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>ChatServlet</servlet-name>
<url-pattern>/cc</url-pattern>
</servlet-mapping>
</web-app>



server.xml:

<Connector port="8080"
protocol="org.apache.coyote.http11.Http11NioProtocol"
connectionTimeout="20000" useComet="true"
redirectPort="8443" />


what do I miss??
 
L

lightning

At last I fixed this problem.

I googled and I got help from this link http://readlist.com/lists/tomcat.apache.org/users/9/47796.html

Yes,I use an IDE to develop my module, then it copy the catalina.jar
to the WEB-INF/lib.
This cause tomcat6 's "instanceof CometProcessor" check-failed.

So,
1,you must modify server.xml to ensure that your connetor use nio or
apr


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


2,you must make sure that catalina.jar is NOT IN YOUR WEB-INF/lib!

:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top