Results 1 to 2 of 2
  1. #1
    Kenan_89 is offline Member
    Join Date
    Jan 2012
    Posts
    25
    Rep Power
    0

    Default Embed JWebSocket to tomcat and test it

    Hi guys,

    I am trying since yesterday to embed JWebSocket into my
    webapps.

    Which Tomcat I am using?
    I user tomcat apache-tomcat-6.0.20

    What I`ve done until now?
    -I copied jWebSocketAppServer-0.9.0.war into the tomcat webapps file
    -I copied jWebSocketServer-Bundle-0.9.0.jar into the lib file of my webapp called "chat"

    What is the next step? I unfortunatly have no idea :(

    How can I find out, my JWebSocket works correctly?

    I have this code from a html5 book:

    XML Code:
    <!DOCTYPE html>
    <html>
    <head>
    	<title>Websocket</title>
    	<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
    </head>
    <body>
    
    	<form action="#" id="chat_form" method = "post">
    	
    		<input id="msg">
    		
    		<input type="submit" value="senden">
    	
    	</form>
    
    	<script>
    		
    		var websocket = new WebSocket('ws://localhost:8080/');
    	
    		websocket.onopen = function(event){
    			$('#chat').append('<br> Connection...');
    		}
    		
    		websocket.onmessage = function(event){
    			$('#chat').append(event.data);
    		}
    		
    		websocket.onclose = function(event){
    			$('#chat').append("<br> closed");
    		}
    		
    		$(function(){
    			$('form#chat_form').submit(function(e){
    				e.preventDefault();
    				var textfield = $('#msg');
    				websocket.send(textfield.val());
    				textfield.val("");
    			})
    		});
    		
    	</script>
    </body>
    </html>
    Thanks in ahead for help.



    ***EDIT:
    Further I found out I need a class that implements ServletContextListener. But because I user Tomcat 7 in the past
    I cannot assign my projects tomcat 6 server. I need tomcat 6 server because jWebsocket isnt supported by Tomcat 7.
    In an website I read that I have to switch the Servlet API from 3.0 to 2.5. But how can I do this?
    Last edited by Kenan_89; 05-31-2012 at 01:49 PM.

  2. #2
    Kenan_89 is offline Member
    Join Date
    Jan 2012
    Posts
    25
    Rep Power
    0

    Default Re: Embed JWebSocket to tomcat and test it

    Hmm, now I get a text in the console in chrome:

    "Error during WebSocket HandShake. Header is missing"

    What does this mean?

Similar Threads

  1. embed JRE
    By invegat in forum Forum Lobby
    Replies: 1
    Last Post: 02-05-2012, 07:27 AM
  2. Replies: 0
    Last Post: 10-20-2011, 11:10 AM
  3. how to embed .jar in web page?
    By clydedoris in forum New To Java
    Replies: 0
    Last Post: 03-10-2010, 01:54 AM
  4. Replies: 0
    Last Post: 04-05-2008, 01:38 AM
  5. Tomcat In Eclipse - Sysdeo Tomcat Plug-in
    By JavaForums in forum Eclipse
    Replies: 1
    Last Post: 02-13-2008, 11:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •