Java servlet, comet, long polling, websocket: I am consused !!

Discussion in 'Java' started by sl@exabyte, Nov 10, 2012.

  1. sl@exabyte

    sl@exabyte Guest

    I have been reading the above topics for several days, and now utterly
    confused.

    I am trying to to put a server program for char room feature on my web
    site. To make the server program more efficient I am thinking of using
    sockets.

    For the client end, I would to use socket if I can (otherwise AJAX).

    At the server end, PHP or java daemon.

    My questions:

    1.
    a) For the front end, can I use java servlet ? I understand that websocket
    is not generally supported.
    b) Is java servlet supported by browsers generally ?

    2.
    I discover that there are comet, long polling, websocket. I am very confused
    now.

    Can some experts discuss somewhat of all these options ?

    Thanks.
     
    sl@exabyte, Nov 10, 2012
    #1
    1. Advertising

  2. sl@exabyte

    markspace Guest

    On 11/10/2012 6:06 AM, sl@exabyte wrote:
    > a) For the front end, can I use java servlet ?


    No. Servlets are server side technology.

    > b) Is java servlet supported by browsers generally ?


    Never. Servlets are a server side technology.

    However, look at Java applets:
    <http://docs.oracle.com/javase/tutorial/deployment/applet/>

    All GUI browsers on Mac, Linux and Windows that I know of support Java
    applets. Android doesn't: use an app. iOS doesn't: use their ecosystem.
     
    markspace, Nov 10, 2012
    #2
    1. Advertising

  3. sl@exabyte

    sl@exabyte Guest

    > On 11/10/2012 6:06 AM, sl@exabyte wrote:
    >> a) For the front end, can I use java servlet ?

    >
    > No. Servlets are server side technology.
    >
    >> b) Is java servlet supported by browsers generally ?

    >
    > Never. Servlets are a server side technology.
    >
    > However, look at Java applets:
    > <http://docs.oracle.com/javase/tutorial/deployment/applet/>
    >
    > All GUI browsers on Mac, Linux and Windows that I know of support Java
    > applets. Android doesn't: use an app. iOS doesn't: use their
    > ecosystem.


    My apology, 'java servlet' should be 'java applet'.

    I think coding in java applet allows access to sockets.

    Thanks.
     
    sl@exabyte, Nov 10, 2012
    #3
  4. sl@exabyte

    markspace Guest

    On 11/10/2012 8:21 AM, sl@exabyte wrote:java applet'.
    >
    > I think coding in java applet allows access to sockets.



    Yes it does.

    <http://docs.oracle.com/javase/tutorial/networking/sockets/index.html>

    <http://docs.oracle.com/javase/7/docs/api/java/net/Socket.html>

    <http://docs.oracle.com/javase/7/docs/api/java/net/ServerSocket.html>
     
    markspace, Nov 10, 2012
    #4
  5. In article <k7ln1q$id0$>,
    "sl@exabyte" <> wrote:

    > I have been reading the above topics for several days, and now utterly
    > confused.
    >
    > I am trying to to put a server program for char room feature on my web
    > site. To make the server program more efficient I am thinking of using
    > sockets.
    >
    > For the client end, I would to use socket if I can (otherwise AJAX).
    >
    > At the server end, PHP or java daemon.
    >
    > My questions:
    >
    > 1.
    > a) For the front end, can I use java servlet ? I understand that websocket
    > is not generally supported.
    > b) Is java servlet supported by browsers generally ?
    >
    > 2.
    > I discover that there are comet, long polling, websocket. I am very confused
    > now.
    >
    > Can some experts discuss somewhat of all these options ?
    >
    > Thanks.



    I'm using WebSockets with Jetty. It generally works well for two-way
    text messaging and it doesn't interfere with REST/Servlet APIs. Recent
    but important features, like ping/pong and different message types,
    aren't supported by browsers. There's also zero error handling defined
    so you'll need to work that in.

    Tomcat has experimental support for WebSockets but I recommend Jetty
    instead.
    --
    I will not see posts from Google because I must filter them as spam
     
    Kevin McMurtrie, Nov 10, 2012
    #5
  6. sl@exabyte

    sl@exabyte Guest

    Kevin McMurtrie wrote:
    > In article <k7ln1q$id0$>,
    > "sl@exabyte" <> wrote:
    >
    >> I have been reading the above topics for several days, and now
    >> utterly confused.
    >>
    >> I am trying to to put a server program for char room feature on my
    >> web site. To make the server program more efficient I am thinking of
    >> using sockets.
    >>
    >> For the client end, I would to use socket if I can (otherwise AJAX).
    >>
    >> At the server end, PHP or java daemon.
    >>
    >> My questions:
    >>
    >> 1.
    >> a) For the front end, can I use java servlet ? I understand that
    >> websocket is not generally supported.
    >> b) Is java servlet supported by browsers generally ?
    >>
    >> 2.
    >> I discover that there are comet, long polling, websocket. I am very
    >> confused now.
    >>
    >> Can some experts discuss somewhat of all these options ?
    >>
    >> Thanks.

    >
    >
    > I'm using WebSockets with Jetty. It generally works well for two-way
    > text messaging and it doesn't interfere with REST/Servlet APIs.
    > Recent but important features, like ping/pong and different message
    > types, aren't supported by browsers. There's also zero error
    > handling defined so you'll need to work that in.
    >
    > Tomcat has experimental support for WebSockets but I recommend Jetty
    > instead.


    Just curious, have you thought about using javacript with java applet ?

    If yes, what made you choose WebSockets with jetty ?

    Thanks.
     
    sl@exabyte, Nov 11, 2012
    #6
  7. sl@exabyte

    sl@exabyte Guest

    Kevin McMurtrie wrote:
    >
    > I'm using WebSockets with Jetty. It generally works well for two-way
    > text messaging and it doesn't interfere with REST/Servlet APIs.
    > Recent but important features, like ping/pong and different message
    > types, aren't supported by browsers. There's also zero error
    > handling defined so you'll need to work that in.
    >
    > Tomcat has experimental support for WebSockets but I recommend Jetty
    > instead.


    Just thinking. If javascript can communicate with java applet (which can
    access sockets), why bother to have websocket ?

    Forgive me if this is a stupid question.
     
    sl@exabyte, Nov 11, 2012
    #7
  8. > I think coding in java applet allows access to sockets.

    Except clients behind http proxy.
     
    William Bonawentura, Nov 12, 2012
    #8
  9. sl@exabyte

    sl@exabyte Guest

    William Bonawentura wrote:
    >> I think coding in java applet allows access to sockets.

    >
    > Except clients behind http proxy.


    Thanks for your info. I have heard of proxy server, but not bothered with it
    so far.

    I did some 'google'ing on proxy server. My current understanding is the
    proxy server may block the communication port. So to enable the
    administrator needs to give permission to use this port.

    Would MSN have the same problem ? Thanks for your guide.
     
    sl@exabyte, Nov 12, 2012
    #9
  10. In article <k7o9a4$k8q$>,
    "sl@exabyte" <> wrote:

    > Kevin McMurtrie wrote:
    > > In article <k7ln1q$id0$>,
    > > "sl@exabyte" <> wrote:
    > >
    > >> I have been reading the above topics for several days, and now
    > >> utterly confused.
    > >>
    > >> I am trying to to put a server program for char room feature on my
    > >> web site. To make the server program more efficient I am thinking of
    > >> using sockets.
    > >>
    > >> For the client end, I would to use socket if I can (otherwise AJAX).
    > >>
    > >> At the server end, PHP or java daemon.
    > >>
    > >> My questions:
    > >>
    > >> 1.
    > >> a) For the front end, can I use java servlet ? I understand that
    > >> websocket is not generally supported.
    > >> b) Is java servlet supported by browsers generally ?
    > >>
    > >> 2.
    > >> I discover that there are comet, long polling, websocket. I am very
    > >> confused now.
    > >>
    > >> Can some experts discuss somewhat of all these options ?
    > >>
    > >> Thanks.

    > >
    > >
    > > I'm using WebSockets with Jetty. It generally works well for two-way
    > > text messaging and it doesn't interfere with REST/Servlet APIs.
    > > Recent but important features, like ping/pong and different message
    > > types, aren't supported by browsers. There's also zero error
    > > handling defined so you'll need to work that in.
    > >
    > > Tomcat has experimental support for WebSockets but I recommend Jetty
    > > instead.

    >
    > Just curious, have you thought about using javacript with java applet ?
    >
    > If yes, what made you choose WebSockets with jetty ?
    >
    > Thanks.


    Applets are uncommon and so are developers for them. Sun screwed up the
    Applet and GUI APIs over and over again right when Applets were needed.
    HTML5 features create interactive GUIs far more easily and efficiently
    than anything from Sun or Oracle.

    WebSockets were chosen because they were a very simple way to provide
    realtime two-way communications between client and server.

    Jetty was chosen because it appears that it receives aggressive
    refactoring to keep the code lean and clean. WebSocket support is
    mature and cleanly integrated. Jetty also has clear layering that makes
    it possible for unit tests to build a mini environment for invoking
    Servlets. The downside is that configuration documentation is
    incomplete.
    --
    I will not see posts from Google because I must filter them as spam
     
    Kevin McMurtrie, Nov 13, 2012
    #10
  11. In article <>,
    jebblue <> wrote:

    > On Sat, 10 Nov 2012 13:23:41 -0800, Kevin McMurtrie wrote:
    >
    > > In article <k7ln1q$id0$>,
    > > "sl@exabyte" <> wrote:
    > >
    > >> I have been reading the above topics for several days, and now utterly
    > >> confused.
    > >>
    > >> I am trying to to put a server program for char room feature on my web
    > >> site. To make the server program more efficient I am thinking of using
    > >> sockets.
    > >>
    > >> For the client end, I would to use socket if I can (otherwise AJAX).
    > >>
    > >> At the server end, PHP or java daemon.
    > >>
    > >> My questions:
    > >>
    > >> 1.
    > >> a) For the front end, can I use java servlet ? I understand that websocket
    > >> is not generally supported.
    > >> b) Is java servlet supported by browsers generally ?
    > >>
    > >> 2.
    > >> I discover that there are comet, long polling, websocket. I am very
    > >> confused
    > >> now.
    > >>
    > >> Can some experts discuss somewhat of all these options ?
    > >>
    > >> Thanks.

    > >
    > >
    > > I'm using WebSockets with Jetty. It generally works well for two-way
    > > text messaging and it doesn't interfere with REST/Servlet APIs. Recent
    > > but important features, like ping/pong and different message types,
    > > aren't supported by browsers. There's also zero error handling defined
    > > so you'll need to work that in.
    > >
    > > Tomcat has experimental support for WebSockets but I recommend Jetty
    > > instead.

    >
    > Jetty doesn't even have a clean start/stop CLI interface like
    > Tomcat has had all along. Tomcat is the basis for all major
    > Enterprise Java web servers.


    Why the totally off-topic reply about the start/stop procedure?

    /opt/jetty/bin/jetty.sh stop
    /opt/jetty/bin/jetty.sh start

    Or use the init.d scripts. That looks a lot like Tomcat.

    I recommend using the server best supports the features you need.
    Software developers aren't paid lots of money to make decisions based on
    FUD. There's good reason for Restlet, Jetty, Resin, Tomcat, and other
    engines existing.
    --
    I will not see posts from Google because I must filter them as spam
     
    Kevin McMurtrie, Nov 29, 2012
    #11
  12. sl@exabyte

    Silvio Guest

    On 11/23/2012 06:26 PM, jebblue wrote:
    > On Sat, 10 Nov 2012 13:23:41 -0800, Kevin McMurtrie wrote:
    >
    >> In article <k7ln1q$id0$>,
    >> "sl@exabyte" <> wrote:
    >>
    >>> I have been reading the above topics for several days, and now utterly
    >>> confused.
    >>>
    >>> I am trying to to put a server program for char room feature on my web
    >>> site. To make the server program more efficient I am thinking of using
    >>> sockets.
    >>>
    >>> For the client end, I would to use socket if I can (otherwise AJAX).
    >>>
    >>> At the server end, PHP or java daemon.
    >>>
    >>> My questions:
    >>>
    >>> 1.
    >>> a) For the front end, can I use java servlet ? I understand that websocket
    >>> is not generally supported.
    >>> b) Is java servlet supported by browsers generally ?
    >>>
    >>> 2.
    >>> I discover that there are comet, long polling, websocket. I am very confused
    >>> now.
    >>>
    >>> Can some experts discuss somewhat of all these options ?
    >>>
    >>> Thanks.

    >>
    >>
    >> I'm using WebSockets with Jetty. It generally works well for two-way
    >> text messaging and it doesn't interfere with REST/Servlet APIs. Recent
    >> but important features, like ping/pong and different message types,
    >> aren't supported by browsers. There's also zero error handling defined
    >> so you'll need to work that in.
    >>
    >> Tomcat has experimental support for WebSockets but I recommend Jetty
    >> instead.

    >
    > Jetty doesn't even have a clean start/stop CLI interface like
    > Tomcat has had all along. Tomcat is the basis for all major
    > Enterprise Java web servers.
    >


    That is utter nonsense.
     
    Silvio, Nov 29, 2012
    #12
  13. On 12/07/2012 02:09 AM, jebblue wrote:
    > On Wed, 28 Nov 2012 21:02:59 -0800, Kevin McMurtrie wrote:
    >

    [ SNIP ]
    >
    >> I recommend using the server best supports the features you need.
    >> Software developers aren't paid lots of money to make decisions based on
    >> FUD. There's good reason for Restlet, Jetty, Resin, Tomcat, and other
    >> engines existing.

    >
    > FUD? Nope. Mistake yes, FUD no, not at all. When WebSphere or
    > WebLogic decide to switch to Jetty I'll look at it again.
    >

    I'm with Kevin on this one. And bear in mind, when you say "WebSphere"
    or "WebLogic" it's not like you've got this dedicated team of web
    container experts, with each app server development staff, that
    constantly evaluates servlet containers and gets their decisions quickly
    acted upon.

    In practice the resources allocated for software development on a major
    JEE app server are less than you might think. Most are probably either
    fixing bugs or designing/implementing new features (which latter is
    driven by the marketers). If an included/embedded web/servlet container
    is cutting it, and that original choice probably came down to one or a
    small handful of people way back when (so why do they know more than
    you, exactly?), and the cost of *change* is probably not justifiable for
    incremental improvements achieved by using another container, why do you
    think that what a major app server uses gives you any major guidance at all?

    Other than that what they use is good for them. It's possibly not the
    _best_ for them at any given time. It's very possibly not the best
    choice for anyone else's requirements, although you can expect it to be
    adequate.

    AHS
     
    Arved Sandstrom, Dec 7, 2012
    #13
  14. sl@exabyte

    Roedy Green Guest

    On Fri, 23 Nov 2012 11:26:14 -0600, jebblue <> wrote, quoted or
    indirectly quoted someone who said :

    >>> b) Is java servlet supported by browsers generally ?


    Servlets run on the Server. To the browser client they just look like
    static web pages. You can run some intelligence such as Ajax, Applets
    or JWS at the client. Then you can send any message format you want
    back and forth.

    see http://mindprod.com/jgloss/servletwomb.html

    For very high speed communication, you use UDP packets. The catch is,
    there is no guaranteed delivery. But often that may not matter if all
    you are doing is apprising each other of current state.

    See http://mindprod.com/jgloss/udp.html
    --
    Roedy Green Canadian Mind Products http://mindprod.com
    Students who hire or con others to do their homework are as foolish
    as couch potatoes who hire others to go to the gym for them.
     
    Roedy Green, Dec 9, 2012
    #14
  15. On 11/23/2012 12:26 PM, jebblue wrote:
    > On Sat, 10 Nov 2012 13:23:41 -0800, Kevin McMurtrie wrote:
    >> I'm using WebSockets with Jetty. It generally works well for two-way
    >> text messaging and it doesn't interfere with REST/Servlet APIs. Recent
    >> but important features, like ping/pong and different message types,
    >> aren't supported by browsers. There's also zero error handling defined
    >> so you'll need to work that in.
    >>
    >> Tomcat has experimental support for WebSockets but I recommend Jetty
    >> instead.

    >
    > Jetty doesn't even have a clean start/stop CLI interface like
    > Tomcat has had all along.


    No.

    Jetty comes with CLI script to start/stop.

    > Tomcat is the basis for all major
    > Enterprise Java web servers.


    No.

    WebSphere and WebLogic come with own.

    JBoss uses Tomcat and Glassfish uses a modified Tomcat.

    Arne
     
    Arne Vajhøj, Dec 9, 2012
    #15
  16. On 12/7/2012 1:09 AM, jebblue wrote:
    > On Wed, 28 Nov 2012 21:02:59 -0800, Kevin McMurtrie wrote:
    >> /opt/jetty/bin/jetty.sh stop
    >> /opt/jetty/bin/jetty.sh start
    >>
    >> Or use the init.d scripts. That looks a lot like Tomcat.
    >>

    >
    > Thanks, guess I didn't look far enough.


    Given that it is in the same location as for Tomcat, then
    it appears that you have not been looking at all.

    > Tomcat is still the basis of
    > every major enterprise Java platform.


    Still not.

    >> I recommend using the server best supports the features you need.
    >> Software developers aren't paid lots of money to make decisions based on
    >> FUD. There's good reason for Restlet, Jetty, Resin, Tomcat, and other
    >> engines existing.

    >
    > FUD? Nope. Mistake yes, FUD no, not at all. When WebSphere or
    > WebLogic decide to switch to Jetty I'll look at it again.


    They probably prefer their own.

    But heard of a small company called Google?

    They use Jetty!

    Arne
     
    Arne Vajhøj, Dec 9, 2012
    #16
  17. sl@exabyte

    Arne Vajhøj Guest

    On 11/10/2012 11:21 AM, sl@exabyte wrote:
    >> However, look at Java applets:
    >> <http://docs.oracle.com/javase/tutorial/deployment/applet/>
    >>
    >> All GUI browsers on Mac, Linux and Windows that I know of support Java
    >> applets. Android doesn't: use an app. iOS doesn't: use their
    >> ecosystem.

    >
    > My apology, 'java servlet' should be 'java applet'.


    That is a bloody big difference.

    > I think coding in java applet allows access to sockets.


    It does.

    Server side is more tricky.

    Either a standalone server/daemon program or a full
    Java EE application-server with a JCA inbound adapter.

    And you need to get through all the firewalls, which may
    be easy or may be impossible.

    Arne
     
    Arne Vajhøj, Dec 11, 2012
    #17
  18. sl@exabyte

    Arne Vajhøj Guest

    On 11/11/2012 8:37 AM, sl@exabyte wrote:
    > Just thinking. If javascript can communicate with java applet (which can
    > access sockets), why bother to have websocket ?
    >
    > Forgive me if this is a stupid question.


    Actually it is a pretty good question.

    Java applets are out of fashion - JavaScript is in fashion.

    There are or will soon be 1 billion smartphones with browsers
    without applet support.

    A Java-JavaScript solution is more complex than a pure
    JavaScript solution.

    But that said, then I still consider the Java applet
    solution to be a perfectly viable solution that must be
    considered.

    Arne
     
    Arne Vajhøj, Dec 11, 2012
    #18
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mihael
    Replies:
    4
    Views:
    1,701
    Knute Johnson
    Mar 7, 2012
  2. Tobias Oberstein
    Replies:
    0
    Views:
    120
    Tobias Oberstein
    Jan 3, 2014
  3. Tobias Oberstein
    Replies:
    0
    Views:
    122
    Tobias Oberstein
    Jan 9, 2014
  4. Replies:
    0
    Views:
    146
  5. å¶æ–°ä¼Ÿ

    Netty5 websocket broadcast, with problem!

    å¶æ–°ä¼Ÿ, Apr 21, 2014, in forum: Java
    Replies:
    0
    Views:
    162
    å¶æ–°ä¼Ÿ
    Apr 21, 2014
Loading...

Share This Page