• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JNI from a servlet

 
igwe kalu kalu ogba
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic