Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8400525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:34:46+00:00 2026-06-09T21:34:46+00:00

I have wrote my websocket server class and wrote ServerPiplineFactory class but I don’t

  • 0

I have wrote my websocket server class and wrote ServerPiplineFactory class but I don’t know to write in MyServerHandler class. MyServerHandler class is like

  public class DiscardServerHandler extends SimpleChannelUpstreamHandler {

private static final String WEBSOCKET_PATH = "/websocket";

@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
    Object msg = e.getMessage();
    //ctx.getChannel().write(msg);
    //msg.getClass();       
    if (msg instanceof HttpRequest) {
        //ctx.getChannel().write(msg);
    } else if (msg instanceof WebSocketFrame) {
        System.out.println("I am WebSocketFrame");          
    }

}

So I don’t know what should I write if I receive HttpRequest and how to send it back to the browser.

So if write something like below in my jsp file

   </script>
   var WEBSOCKET_URL = "ws://localhost:8090/websocket";
   $(document).ready(function() {
   ws = new WebSocket(WEBSOCKET_URL);


  ws.onopen = function(event) {  
 alert("test");
 $('#status').text("Waiting...."); 
  };

  ws.onmessage = function(event) {
  var message = jQuery.parseJSON(event.data);
  alert(message);
 }

  var encoded = $.toJSON("test message");
  ws.send(encoded);

  });
  </script>
  <body>
  <p id="status">&nbsp;</p>
  </body>

and debug this jsp then it goes to messageReceived then I don’t understand what to do then to how websocket server comunicate with server.

So if someone can help me to find the document on this or explain a bit about this that would be great.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T21:34:48+00:00Added an answer on June 9, 2026 at 9:34 pm

    You will need to issue the handshake. Have a look at the websocket example at [1].

    [1] https://github.com/netty/netty/blob/3/src/main/java/org/jboss/netty/example/http/websocketx/server/WebSocketServerHandler.java

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a little Problem but don't know the Solution! I have wrote a
i have wrote the visitor pattern as follow but i don't understand what is
I have wrote below code. import java.io.*; class Test { public static void main(String
i have wrote the following polymorphic code: public abstract class A { readonly int
I have wrote a method to convert any layout Liner,Relative,Frame etc into Bitmap but
I have wrote a custom MultipleChoiceField. I have everything working ok but when I
i have wrote a script to produce an array of data but now want
I have wrote a function like , private function addSelectedFunc():void { /** * Adds
I already have a server with port and want to write a web app
I am trying to built a websocket application in IE9 but I have the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.