WebSocket (Tutorial 01 – Java Server + JavaScript Client + GlassFish 4.0 + JDK 1.7)
Articles,  Blog

WebSocket (Tutorial 01 – Java Server + JavaScript Client + GlassFish 4.0 + JDK 1.7)

What is a tutorial covering WebSocket endpoint Java Server + JavaScript client? How to update eclipse w/ the GlassFish Tools? How to define The GlassFish Server Runtime Environment on Eclipse? What does the GlassFish Server Runtime require? What is a ServerEndpoint? What is the websocket OnOpen annotation? What is the websocket OnClose annotation? What is the OnError annotation? What is the OnMessage annotation? How to send and receive websocket String messages in ServerEndpoint? What is a simple WebSocket JavaScript client? How to send and receive messages from a webSocket JavaScript client? What is a JavaScript WebSocket onopen event? What is a JavaScript WebSocket onclose event? What is a JavaScript WebSocket onerror event? What is a JavaScript WebSocket onmessage event?


  • V H

    Thank you – Excellent Video(s) I have ported over this example into grails here is the  demo project : https://github.com/vahidhedayati/grails-websocket-example I will also implement the chat example into the same project… Its just basic Grails 2.3.7 under Java 1.7  (No Glassh fish required)

  • Anand Venkatraman

    Yet to try this, but my honest feedback, lot of 'Iam gonna be…' being said by you, please avoid those…but example from the outset looks very practical hands on…thanks for that.

  • Bodhisattva

    I'd like to ask you something, i've got two aplications to connect to the web service one in a android device and the another in a pc. How can the service to distinguish each one if i declare both clients in the HTML file?.

  • Anand Maheshwari

    Not able to receive message from server that is concated with echo text on html page.

    Not able to get source code also.

  • Sanal S

    I am new to web sockets and need a hint for this tutorial. There are 5 videos in between "Tutorial 9" and "Tutorial 13" in your playlist that are not numbered. Do I have to go in that specific order to understand it perfectly or are they just random.

  • NEKOmancer

    This is not an tutorial… This is more like an walkthru, where you only talks about what you do. But do not explain why you do it. If I follow strictly what you are doing I might be able to get a product, but hell I really want to know why are you doing the stuffs.

  • Almost787

    Thank you very much – your tutorial is really great and helped me to understand it 🙂 I did it with IntelJ and Maven here are some code that helped me to start the Server:
    In the Server class you can Add this (this allows you to start the server from any IDE directly):
    public static void main(String[] args) throws Exception {
    Server server = new Server("localhost", 8080, "/websockets", null, ServerEndpointDemo.class); //I used the WS PATH localhost:8080/websockets/
    System.out.println("Server started, press a key to stop the server");
    Additionally I added in my POM the fallowing dependencies


    My Version is running with JDK1.9 and it would probably run with a higher JDK Verison

  • zaneacademy

    WebSocket Security Tutorial – Setup and run on both GlassFish 4.1 & Tomcat 8 @ https://youtu.be/Am5eTQ-sQn4
    WebSocket Tutorial 15 – ServerEndpoint + CDI + Stateless, Stateful, and Singleton Session Beans @ https://youtu.be/McifXIboiRk
    WebSocket Tutorial 14 – WebSocket Path Mapping + Java Servlet + HttpSession + glassFish 4 + tomcat 8 @ https://youtu.be/92fM1JPqDVI
    WebSocket Tutorial 13 – ServerEndpoint + Java Servlet + HttpSession + glassFish 4 + tomcat 8 @ https://youtu.be/YE8my5AF67s
    WebSocket Java Swing Sketch App. Tutorial (Tomcat 8 + Java 8) @ https://youtu.be/BzQ9KUbfLek
    WebSocket JavaScript Sketch App. Tutorial @ https://youtu.be/wU-FRsLky3Q
    WebSocket JavaFX Sketch App. Tutorial (Tomcat 8 + Java 8) @ https://youtu.be/2xgnSpcAVzE
    WebSocket Tutorial 09 (ClientEndpoint JavaFX chat app w/ encoders & decoders) @ https://youtu.be/0nTqlVOI2Rc
    WebSocket Tutorial 08 (JavaFX Programmatic ClientEndpoint Chat App.) @ https://youtu.be/EVL7fUTrFl4
    WebSocket Tutorial 07 – ClientEndpoint Java Application @ https://youtu.be/KVPXQWJagDg
    WebSocket Tutorial 06 (roundtrip JSON + Message handling) @ https://youtu.be/KmSpk8XWeQY
    WebSocket Tutorial 05 (Programmatic Endpoint chatroom web app.) @ https://youtu.be/nLe8vuxW8b4
    WebSocket Tutorial 04 (Enhanced chatroom web application) @ https://youtu.be/NjUbKcEcLQA
    WebSocket Tutorial 03 (encoders & decoders in a simple chatroom web app.) @ https://youtu.be/4nWZ2Oog_w8
    WebSocket Tutorial 02 (Simple chatroom web app. – Java ServerEndpoint + JavaScript Client) @ https://youtu.be/BikL52HYaZg
    WebSocket (Tutorial 01 – Java Server + JavaScript Client + GlassFish 4.0 + JDK 1.7) @ https://youtu.be/_Fi4vz6oUio

Leave a Reply

Your email address will not be published. Required fields are marked *