Has anyone experience with using JNI within Servlets running on Tomcat?

Specifically, I have legacy applications that are using some form of Unix/Linux IPC (what type not known yet) and they are currently using CGI scripts with linked in C++ libraries for communication via IPC. The big problem with that being, more than one web client spawns multiple CGI/IPC connections and apparently that breaks their current scheme.

Now I come into the picture and say... Hey - what about using Servlets with JNI (or at worst/best a socket connection to another C++ arbiter program) that is responsible for talking via IPC to the legacy software?

With the Java Servlets - you have one instance of the program and multiple threads for each web client.

My problem is - I have little experience with servlets and I do not know whether you can use something like JNI within the sandbox. Common sense tells me otherwise.


I'm looking for any advice or for your favorite web forum where this would be more appropriate.

Thank you.