3 Replies Latest reply on Jul 17, 2008 4:52 AM by nightnic

    PHP-Servlet-EJB - design choice?

      Hi,

      I'm looking into implementing an EJB-based service for integration into existing web-site. Website is written on PHP and hosted on standard ISP hosting. There is also a dedicated server which is the base for business logic processing.

      My goal is to implement business logic processing using high-level language with adequate debugging abilities, e.g. Java, employ HTTP-based connectivity and make little change to existing website code.

      Here is design I came up with: there is a PHP class on website-side, which provides business logic methods (i.e. getProductListing(), sendOrder() and such).
      This class translates incoming method calls to HTTP requests on socket, which connects to a servlet on dedicated server. The servlet handles requests with help of EJB and sends back an XML response. XML response received by same PHP wrapper class, processed with XSLT and displayed on web site page.
      Servlet and EJB running under JBoss AS.

      Here go the questions:

      1. Is there anything to be improved in this design?

      2. There is an issue of handling session contexts. Servlet cannot discern users, since from its standpoint, there is only one connection source - PHP wrapper class. So there is need for PHP wrapper to manually supply JSESSIONID cookie from servlet to the browser and back.
      Do you think there is any better way to handle this?

      3. Which is the best way to handle session context on servlet/EJB side? I'm looking at JBoss Seam, but not convinced it will do because of previous issue. I'm looking into manually implementing session context tracking on servlet side, but there probably is a better solution?

      Please let me know your opinion on this design. Feedback is much appreciated.

        • 1. Re: PHP-Servlet-EJB - design choice?
          jfclere

          1) Mixing PHP and JAVA is not easy.
          2) -Dorg.apache.catalina.JSESSIONID=PHPSESSIONID so that servlets will use the same sessionid (you will have to store the session information and restore it.
          3) See 2)

          The phpservlet in JBossWEB is designed for a migration tool for PHP to JAVA but it may fit to your needs.

          • 2. Re: PHP-Servlet-EJB - design choice?

            Thanks for your feedback!

            In 2) do you mean I still have to manually implement session context handling from scratch, or that I have to use servlet session to store context-related objects in it?

            I will check the phpservlet, was't aware about it, thanks!

            • 3. Re: PHP-Servlet-EJB - design choice?

              Seems like phpservlet runs in context of a java as. This does not go along well with my constraint of leaving PHP on the website hosting, which does not allow use of any java. So there is need to somehow communicate user requests from PHP to the servlet.