#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    7
    Rep Power
    0

    Servlet<-->Perl script


    I have some questions about a server side solution for an interface between a Perl script and a Servlet.

    I am running on a OpenBSD testbox an apache Webserver with Perl CGI that serves several forms etc. and reads/writes to a database, which is for the moment a flat file (if later neccesary I transfer it to MySQL). I also want to make a more simple gateway for midp phones to the same app and add some other functionality to it. I want to use java servlets for that.

    In order to have the servlet(s) integrated with the Perl script I will have to make an interface. I will adjust the script to make that possible, I thought it would be best if I keep the script as the only program that can write to the database.

    My questions are: Do I need an Applicationserver for that, or will Tomcat do just fine? At the moment only JDK 1.2.2 is available on OpenBSD, so will that restrict me in my programming?


    Any other comments/suggestions are also welcome!

    Thanks
  2. #2
  3. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    You can use Tomcat if all you want to do is servlets/jsp. And app server like jboss is only needed for EJB's.

    As for your second question, I do not know what jre Tomcat requires, but I am sure you could find out from the web site. Also, older version of Tomcat are available that may run on older JRE's. Again, see the Tomcat web site.

    As for using your perl scripts in a servlet, you can easily "include" a perl script in a servlet call and have it be transparent to the user. Servlets can call other web pages of any kind in their processing and control will returned to the servlet after the call. Not sure if you were aware of that since it sounded like you wanted to make some sort of interface for it.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    7
    Rep Power
    0
    You are right, I was thinking too complicated. There is no need for an app server. What I want is the servlet to be only reachable by the mobile device and adjust the perl script so that it handles also the requests from the servlet. I want different functionality for the mobile device compared to the regular use of the perl script ( through browser) so I will have to add some functions, which should not be accessable by a browser. That is what I meant by interface (realizing now it was a wrong choice of words). I know it is not even necessary to use servlets and that the phone app can talk directly to the perl script instead, but I would like to use a servlet.

    Because I was(/am?) not quite sure if I wanted the servlet to talk to the database directly or that I would implement it as I described above, I was not sure what I would need (app server or just Tomcat)

    Reading it back I realize it is maybe pretty fuzzy what I am writing, but I hope you'll be gentle
  6. #4
  7. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    No problem. Have you got the answers you were looking for or did you still have a question? I could not quite tell if you got what you were seeking.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    7
    Rep Power
    0
    At this moment I am still not sure if I should have the servlet talk to the database directly or that I would let that be handled through the perl script (send al the parameters from the servlet to the script that in it's turn accesses the database)

    If I parse everything from the servlet to the script than I don't have to change anything to the database (now a file), but I guess that if I use MySQL the appropriate filelocking will be handled by MySQL (servlet--> MySQL <--perl). I would in that case have to implement the JDBC driver.

    This is basically the question I keep asking myself: Do I implement a direct servlet <--> database connection or a servlet <--> perl <--> database connection.
  10. #6
  11. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    Here is how I see it - if you have a working setup using perl that does everything you need, then I would reuse this code to make your job easier. If you do an 'include' on the perl script from in the servlet I believe it should pass on all the request parameters intact, just as if the user requested the perl script itself. It really should be that easy. No need to manually readd all the stuff to the request.

    However, if you do not like that way the perl script does it's thing, then now might be the time to change it. Or you could write the servlet so that it uses the existing perl script/flat file system until such a time as you change it in the future to use a database. The nice thing is that it will be transparent to the user because the url will not change.

IMN logo majestic logo threadwatch logo seochat tools logo