Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JNI from a servlet

 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
I will suppress my every urge. But not this shameless plug:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic