tags:

views:

97

answers:

2

Hi friends,

         how to use JNI in JSP page?.In net i found that

1. because if anything goes seriously wrong in the C part of your application, it will very likely crash your J2EE server, downing all other web services and applications it is running.

  1. because the 'reactivatable' nature of web applications means there is no guarantee that a static initializer will not be executed more than once during one JVM run.
+1  A: 

Unless you're confident of the reliability of your JNI-linked library, I'd strongly recommend not doing this, for the reasons you've identified.

I'd recommend decoupling the application server from your native code, and make the native library available via some remote mechanism (e.g. web service / REST / simple socket). That way you've isolated the app server from any fatal problems related to the native code.

Brian Agnew
Not sure, not sure. For example, we use Java advanced image io (which includes JNI part) for image resizing from our servlets, and it works stellar.
alamar
Ultimately everything goes to native code. If you're confident of the provenance and reliability of that JNI code + library, then link to it directly. In the environments I typically work in, I can't/won't make that assumption unless I'm very sure of the reliability.
Brian Agnew
I've edited appropriately, to reflect the above
Brian Agnew
A: 

From Java code, JNI looks like regular methods on classes, so you just call those methods, and JNI libraries get executed,

Of course you can do that, another question is that JNI can always be misused. So please be more specific, right now your question doesn't make much sense.

alamar
Hi friends,i got the solution for this post.But in servlet i got the solution.i) create servlet(.java)ii)compile and get the .class fileiii) using javah create headerfile.iv) using VC create .dll(in same path)v) copy the .dll file System32 folder or lib folder in apache tomcatvi) type the URL and get the o/p.vii)if system32 folder in classpath u dont want to type System.load u can left just simple as LoadLibrary()thanks a lot,krishna
krishnakumar