aspose file tools*
The moose likes Java Micro Edition and the fly likes GPRS + J2ME Related queires Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "GPRS + J2ME Related queires" Watch "GPRS + J2ME Related queires" New topic
Author

GPRS + J2ME Related queires

Trupti Mehta
Ranch Hand

Joined: Oct 08, 2000
Posts: 79

Hello,

I have developed a pure J2ME application and its working on any mobile phone with any platform. Now I got to implement SMS feature, and add details of a form in a file on the server. For this I will nedd GPRS.

I don't know how to implement this. can I assign attributes like "method="POST" action=urlToServlet" in a J2ME form and call a Servlet to do the saving in a file on server. OR implement HttpConnection directly on OK button of the form.
I also need to check up if the phone has GPRS access or not, if Yes, then connect to Internet and then proceed.

And Yes, after implementing GPRS feature, will the application run on all platforms like its wokring now on Windows Mobile, Blackberry, Symbian, etc.

Can you please guide me what to do and how to do the same. Try to help at your earliest.

Thanks.


Regards,
Trupti (SCJP)
Ahmed Abdul Baqi
Greenhorn

Joined: Apr 24, 2009
Posts: 8

Trupti Mehta
Ranch Hand

Joined: Oct 08, 2000
Posts: 79

Ahmed Abdul Baqi wrote:


Thanks Ahmed. But things are a bit confusing for me, it would be better if you can solve it.
You get connected to a servlet lying on web server. Then you open outputstream, add username and password to request and writing your request into bytes using the outputstream. Similarly with input sream you are reading till end of file.
> passing the two string as a request along with the url to the server
I am not understanding what exactly and how you are doing.

I also retrieve data from textFields of a form, and have to save them to a file lying on the server. Can you help me code how do I do this? Pass the parameters to the Servlet and do file saving operation in the servlet or directly access the fie lying on the server and save the details. Which option is better and how to code it? I can't make out and am confused.

Would be greatful if you can help me out.

Thanks
Ahmed Abdul Baqi
Greenhorn

Joined: Apr 24, 2009
Posts: 8
Thanks Ahmed. But things are a bit confusing for me, it would be better if you can solve it.
You get connected to a servlet lying on web server. Then you open outputstream, add username and password to request and writing your request into bytes using the outputstream. Similarly with input sream you are reading till end of file.
> passing the two string as a request along with the url to the server
I am not understanding what exactly and how you are doing.

I also retrieve data from textFields of a form, and have to save them to a file lying on the server. Can you help me code how do I do this? Pass the parameters to the Servlet and do file saving operation in the servlet or directly access the fie lying on the server and save the details. Which option is better and how to code it? I can't make out and am confused.

Would be greatful if you can help me out.

Thanks

this is the midlet copy and paste it in the eclipse ide or editplus...read the commments

The servlet part just create a folder and run this servlet on your local system read the comments Let me know if you are able to understand

>
Trupti Mehta
Ranch Hand

Joined: Oct 08, 2000
Posts: 79

Oh Ahmed, Thanks for this help. I wrote a servlet to save the contents in a file over the server and it is working perfectly (atleast with emulator).

But am facing coupl of problems. My Servlet code - that passes "success" or "failure":-

Midlet Code that reads the servlet response :


The problem is on results of servlet, I see the original form only, and not the alert that have added for "Success" or "Failure" message. From System.out.println, I came to know that its a success amd checked the file, data was added. So came to know. Can you point out where am I wrong which makes it go to the form back instead of alert.
Ahmed Abdul Baqi
Greenhorn

Joined: Apr 24, 2009
Posts: 8
do one thing on the servlet side send a response to the midlet if it is success or fialure and read the response on the midlet you are giving the failure in the exception it is not necessary that every time there will be an exception....so as the file is sent to the server send a success and if not send then send a failure and keep the whole code in try.....so save the response from the midlet that you are reading in a variable and check if that variable is empty or not if it is empty than send the response from the servlet as failure and if it is not null then send as success.....that will solve your problem....
Trupti Mehta
Ranch Hand

Joined: Oct 08, 2000
Posts: 79

Right Ahmed. Why that simple thought didn't come in my mind?

Thanks a lot.

Ahmed, can you help me guide on http://www.coderanch.com/t/443507/Java-Micro-Edition/Mobile/Sending-SMS-form-J2ME" target="_new" rel="nofollow">Sending SMS from J2ME query also.
 
 
subject: GPRS + J2ME Related queires