I am trying understand how to deploy the examples referenced in the Apache Tomcat 7 WebSocket How-To page.
The Application Development section advises reading javadoc on WebSocketServlet class. But looking at the server side code of the examples, none of the classes in the three examples extend WebSocketServlet
, which is what I had expected it to do.
I am returning to servlet development after over a decade and feeling quite lost with all the annotations in these examples. Is there another How-To that has step-by-step simple instructions for getting a WebSocket using servlet up and running?
When you download the distribution of Apache Tomcat (7.0.37 is the latest version at the moment), you will have the examples
web application already deployed. It comes with the WebSocket Examples. You don't have to deploy it yourself.
Start Tomcat and open http://localhost:8080/examples
.
Click WebSocket Examples and pick whatever WebSocket example you want.
You don't have to do anything other than to start Tomcat with bin/catalina.sh run
(or whatever command works for you).
When you look into [TOMCAT_HOME]/webapps/examples
directory, you may want to look at WEB-INF/web.xml
where you see the WebSocket servlets deployed.
Their source code is in [TOMCAT_HOME]/WEB-INF/classes/websocket
directory.
The servlet websocket.echo.EchoMessage
does extend org.apache.catalina.websocket.WebSocketServlet
.
I wonder if I should have asked you about the version of Apache Tomcat you use? Perhaps you use some other not-so-recent version? I recommend to start with the latest version as it worked fine for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With