aspose file tools*
The moose likes Servlets and the fly likes JNI from a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "JNI from a servlet" Watch "JNI from a servlet" New topic
Author

JNI from a servlet

igwe kalu kalu ogba
Ranch Hand

Joined: Feb 03, 2005
Posts: 133
Hello, I'm trying to write a servlet which first of all, checks the windows registry to see if a proxy is being used to connect. If this is the case, it will then get the values for the proxy, i.e http and port. then uses the

System.setProperty("","");

to enable the use of a proxy server.

I found a way to do this using JNI. But it only works when my application is not a servlet. As soon as I add the methods to my servlet it starts messing up.
I've even tried using Runtime as in:

Runtime.getRuntime().load("c:/java/jRegistryKey.dll");

to load the dll, but it doesn't function properly.
Can anyone help explain to me how I can use Jni in a servlet. Or if there is any other way, at least how to get the proxy settings for a computer within a servlet. Many thanks.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12806
    
    5
I found a way to do this using JNI. But it only works when my application is not a servlet. As soon as I add the methods to my servlet it starts messing up.

"starts messing up" is not very clear - does it throw a security exception or what?
Security settings aside, a servlet is just a Java program and should be able to do anything a stand-alone application can do.
You should also include the Java version and servlet container version in your posts.
Bill
steven peh
Greenhorn

Joined: Sep 25, 2002
Posts: 5
Actually last time we did this sort of thing on tomcat, we had problems as well (dont remember the specific exception). But we found out that the dll have to be placed somewhere in tomcat's folders. When running as standalone as long as the dll is in whatever folder your java.library.path System property (when you use the java command) is set to you're all set (in windows you can also dump it in the system32 folder), on an appserver its very different, you have to make sure the dll is placed in whatever is configured as the app server's java.library.path , since you are running within the app servers VM.

Cheers
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JNI from a servlet