Click to See Complete Forum and Search --> : java native interface


guruprasanth
April 16th, 2002, 09:12 PM
from JAVA NATIVE INTERFACE program i have to sent data(object) to servlet and this servlet should contact another jni application and present the data.It need not be purely servlets but it has to be net based.

guruprasanth
April 16th, 2002, 09:12 PM
from JAVA NATIVE INTERFACE program i have to sent data(object) to servlet and this servlet should contact another jni application and present the data.It need not be purely servlets but it has to be net based.

guruprasanth
April 16th, 2002, 09:12 PM
from JAVA NATIVE INTERFACE program i have to sent data(object) to servlet and this servlet should contact another jni application and present the data.It need not be purely servlets but it has to be net based.

Norm
April 17th, 2002, 12:07 PM
Do you have a question? You haven't described you application enough for suggestions.
Where do the various pieces of you code execute? Is the first JNI on a client? How is it related to a Java program/ How does it send data to the servlet? Via HTTP or ? Where does the second jni application execute? On the server or on another client? How is it related to a Java program?

Norm

guruprasanth
April 17th, 2002, 08:41 PM
Thank you for your mail.The first portion of JNI is on client.It recives data from vc++ application and it has to sent data to a server(which can be a servlet).It's the responsibility of servlet to route the data to another JNI application which is also a client and that jni application would sent it to vc++ application (which is also on client)

guruprasanth
April 17th, 2002, 08:41 PM
Thank you for your mail.The first portion of JNI is on client.It recives data from vc++ application and it has to sent data to a server(which can be a servlet).It's the responsibility of servlet to route the data to another JNI application which is also a client and that jni application would sent it to vc++ application (which is also on client)

guruprasanth
April 17th, 2002, 08:41 PM
Thank you for your mail.The first portion of JNI is on client.It recives data from vc++ application and it has to sent data to a server(which can be a servlet).It's the responsibility of servlet to route the data to another JNI application which is also a client and that jni application would sent it to vc++ application (which is also on client)

Norm
April 18th, 2002, 10:27 AM
Some more questions. Why not have the vc++ application communicate directly with the server/servlet?
Is the second client application on the same computer as the first one? Again why not have the native code there receive the communications directly from the server?

If we forget about the native code for a second, could you describe your application as running on three computers, one a server and two clients. The first client sends some data to the server and the server sends some data to the second client.
Now considering the jni, on the first client computer the java program gets the data it is to send from the vc++ program via jni. One the second client computer, the java program passes the data it receives from the server to the native program via jni.
If this is the way it works, what are your questions?

Norm

guruprasanth
April 18th, 2002, 08:43 PM
hi,
thank u for your suggestion.is it possible for vc++ application to directly talk to servlet without com.iam asking u this question because i don't know vc++ and another college of mine is going to do that portion of coding(vc++).
secondly i would like to know how my java code would access my servlet without URL class of java.net.Currently iam trying with url CLASS OF
java.net.i want to know better ways of doing it.

guruprasanth
April 18th, 2002, 08:43 PM
hi,
thank u for your suggestion.is it possible for vc++ application to directly talk to servlet without com.iam asking u this question because i don't know vc++ and another college of mine is going to do that portion of coding(vc++).
secondly i would like to know how my java code would access my servlet without URL class of java.net.Currently iam trying with url CLASS OF
java.net.i want to know better ways of doing it.

guruprasanth
April 18th, 2002, 08:43 PM
hi,
thank u for your suggestion.is it possible for vc++ application to directly talk to servlet without com.iam asking u this question because i don't know vc++ and another college of mine is going to do that portion of coding(vc++).
secondly i would like to know how my java code would access my servlet without URL class of java.net.Currently iam trying with url CLASS OF
java.net.i want to know better ways of doing it.

Norm
April 19th, 2002, 09:45 AM
If the connection between the client and the server uses HTTP, then a program written in any language could talk to a server. The protocol involves the use of either a GET or POST with a standard URL. No magic in using Java vs vc++. Any language capable of using sockets can do it.
I don't know about an application talking "directly to servlet". The application communicates with a server which passes the request to the servlet.

If you don't want to use the URL class you can write the code using Sockets. The URL and URLConnection class does save some coding but it will use HTTP. I am assuming that your servlet runs on an HTTP server and is only accessible via a URL such as: Http://serve.com/servlet/theServlet
If you have something different, then you'll have a different design.

Norm

guruprasanth
April 20th, 2002, 03:18 AM
thank u for your sugeestion.currently iam using
application talking directly to servlet using urlclass with a small amount of test data using url encoding ie, http://serve.com/servlet/theServlet?name=guru.
but for large data it may not be efficent to do
url encoding.can u suggest me an efficient way of doing it.waiting for your response at earliest.

guruprasanth
April 20th, 2002, 03:18 AM
thank u for your sugeestion.currently iam using
application talking directly to servlet using urlclass with a small amount of test data using url encoding ie, http://serve.com/servlet/theServlet?name=guru.
but for large data it may not be efficent to do
url encoding.can u suggest me an efficient way of doing it.waiting for your response at earliest.

guruprasanth
April 20th, 2002, 03:18 AM
thank u for your sugeestion.currently iam using
application talking directly to servlet using urlclass with a small amount of test data using url encoding ie, http://serve.com/servlet/theServlet?name=guru.
but for large data it may not be efficent to do
url encoding.can u suggest me an efficient way of doing it.waiting for your response at earliest.

Norm
April 20th, 2002, 09:06 AM
To send more data, the HTTP POST method would be better. The data is written following the HTTP request header vs on the URL as with the GET method.

Norm

guruprasanth
April 21st, 2002, 11:27 PM
i think http post would be same as url encoding .
iam sending u the javacode of url encoding procedure.but with url encoding iam not able to snet large data.
[javacode]
URL url=new URL("HTTP://MYSERVER/MYSERVLET?DATA=XXX);
[JAVA CODE]
IAM USING THE ABOVE CODE IN APPLICATION AND IN SERVER IAM CALLING REQUEST.GETPARAMETER TO ACESS THE DTAT.
Can u explain ME WITH CODE HOW TO SEND AND ACCESS DATA THROUGH HTTP POST.

guruprasanth
April 21st, 2002, 11:27 PM
i think http post would be same as url encoding .
iam sending u the javacode of url encoding procedure.but with url encoding iam not able to snet large data.
[javacode]
URL url=new URL("HTTP://MYSERVER/MYSERVLET?DATA=XXX);
[JAVA CODE]
IAM USING THE ABOVE CODE IN APPLICATION AND IN SERVER IAM CALLING REQUEST.GETPARAMETER TO ACESS THE DTAT.
Can u explain ME WITH CODE HOW TO SEND AND ACCESS DATA THROUGH HTTP POST.

guruprasanth
April 21st, 2002, 11:27 PM
i think http post would be same as url encoding .
iam sending u the javacode of url encoding procedure.but with url encoding iam not able to snet large data.
[javacode]
URL url=new URL("HTTP://MYSERVER/MYSERVLET?DATA=XXX);
[JAVA CODE]
IAM USING THE ABOVE CODE IN APPLICATION AND IN SERVER IAM CALLING REQUEST.GETPARAMETER TO ACESS THE DTAT.
Can u explain ME WITH CODE HOW TO SEND AND ACCESS DATA THROUGH HTTP POST.

Norm
April 22nd, 2002, 09:59 AM
The HTTP POST method is NOT the same as url encoding. Get some HTML documentation and read about how the POST method works.
To use the POST method with a URLConnection you setDoOutput(true), get an OutputStream and write the data. Physically the data will follow an empty line following the HTTP request header that is sent to the server. On the servlet side, the doPost method is called by the server. There you need to open an inputstream and read the data.

Norm