dcsimg
Servlet's independence and JNI
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Friday, October 26, 2001 04:06 AM

I have such problem. The server is Tomcat 3.2.2 There are 3 frames in html page, in each of them there is 1 servlet with HTML form. There is such algorithm in all servlets: ... public void service(HttpServletRequest request, HttpServletResponse response) {... //if the form is not empty then send some params to C-function //print out the response from C-function ... } For the begining I made one C-library for all servlets and put to it 3 functions with the same algorithm, but with different time to wait: JNIEXPORT jobjectArray JNICALL Java_FastServlet1_getInfo1 (JNIEnv *env, jobject object, jobject   More>>
			
I have such problem.
The server is Tomcat 3.2.2

There are 3 frames in html page, in each of them there is 1 servlet with HTML form.

There is such algorithm in all servlets:
...
public void service(HttpServletRequest request,
HttpServletResponse response)
{...

//if the form is not empty then send some params to C-function

//print out the response from C-function

...
}
For the begining I made one C-library for all servlets and put to it 3 functions with the same
algorithm,
but with different time to wait:

JNIEXPORT jobjectArray JNICALL
Java_FastServlet1_getInfo1
(JNIEnv *env, jobject object, jobjectArray objArray)
{

int sz;
int i;

jstring temp;
jclass clazz;
jobjectArray arr;


//define length of new array here:
sz = (*env)->GetArrayLength(env, objArray);

// find class String:
clazz =
(*env)->FindClass(env,"java/lang/String");

// create new array:
arr = (*env)->NewObjectArray(env,sz*2, clazz,
NULL);

//fill this array:
for (i = 0; i < sz; i++) {

temp =
(jstring)((*env)->GetObjectArrayElement(env, objArray,
i));
(*env)->SetObjectArrayElement(env,arr,
2*i, temp);
(*env)->SetObjectArrayElement(env,arr,
2*i+1, temp);

}
sleep(5);
return arr;
}
This is simulation of time-expensive computations in native libraries of our project already
exists.

When I put data to servlet, with corresponding C-function sleep(25), I have 25 seconds to
check
data input in others frames.

The experiment has shown that servlets are NON-Independent
and sleep() in one function gets SIG_ALARM
while OTHER servlet call OTHER C-function in the SAME lib.

The second experiment has shown that even 3 servlets call 3 different libraries, the effect
still remains.

And the third experiment has shown that 2 different servlet are called from DIFFERENT
browsers (multi-user simulation)
are NON-independent also.
It si clear, that I cannot use access lock to library. I should care about multi-user access.


Can anybody help me? Viel Danke. Many thanks. Bolshoe spasibo. Velike spasibi.

   <<Less
About | Sitemap | Contact