4 Replies Latest reply on Oct 27, 2004 8:04 AM by poojac20

    Posting Again: Can Servlet automatically listen to user-spec

    poojac20

      Sorry for cluttering the forum. I've already asked this question but without an answer. Hence posting again with more clarity.

      Is it possible to configure my servlet in such a way that it listens to a particular port, Say 7001?

      I want my clients to access this servlet NOT thru HTTP request to jboss port 8080 but by posting bytes directly on 7001. The client only knows IP address & port number of the host and has no knowledge of servlet existence. It only knows to send bytes in a particular order on an IP and its particular port. I need JBoss to route all requests on this port to my servlet - and handle multiple requests in the process.

      Will I need to write a separate redirector which listens on the port, wraps these bytes in HTTP and sends them to the servlet ? [And hence get into the mess of managing threads for mutliple clients and sockets]


      Or is it possible to route everything on 7001 to my servlet automatically?

      Thanx for ne insight

      --- Pooja.

        • 1. Re: Posting Again: Can Servlet automatically listen to user-
          robisz

          You can configure a connector on port 7001.
          Check your_jboss_conf/deploy/jbossweb-tomcat50.sar/server.xml.

          But if you want to use HttpServlet you must access it through
          http protocol, of course. But it can't be a problem. See URL and
          HttpURLConnection classes in J2SE API documentation.

          • 2. Re: Posting Again: Can Servlet automatically listen to user-
            poojac20

            Thanx robisz.

            Understood this connector thing now.

            But about using HttpURLConnection, in my case, this will not be possible - my client is a pos terminal which dials on to a modem and which then passes on to some server's specific port. Including a URL is not possible in this scenario.

            I am trying this out - do u think if I extend GenericServlet and write something on my own, that may help - will i still need to access the servlet through some URL? Or I can then expect an automatic call to my process function?

            • 3. Re: Posting Again: Can Servlet automatically listen to user-
              robisz

              It's possible to write non-http servlet, but you need an
              appropriate servlet container that can handle it.

              Are you sure you want to use J2EE?

              As I see, all you need is a plain TCP/IP socket.

              • 4. Re: Posting Again: Can Servlet automatically listen to user-
                poojac20


                Actually, I have most of the business logic already available as EJBs.
                Hence J2ee as back end is already there.

                I need to use these EJBs and am trying to avoid RMI calls through another home-made server.
                And then I also thought IF JBoss can manage multiple sockets/threads/clients on its own , then I can avoid this work.

                It seems Connector can achieve this multiple socket management .. am i right? So the next question is can a servlet (or something else from which I can call EJBs) be automatically called by the container when request comes on a certain port?

                Thanx for the help.